[英]subprocess.Popen will not run my python program
因此,我嘗試為正在制作的文字游戲制作啟動器,並且我需要啟動器根據我選擇的擴展來運行游戲的一部分。 但是,在創建啟動器並對其進行測試之后,我意識到一切正常,直到啟動器應該執行另一個python程序的那一部分為止。 而不是執行程序,它只是結束,我不確定為什么。 這是我的代碼:
import easygui as e
import os
import subprocess
def Launch():
expansions = []
file = open("dlc.txt")
reading = True
while reading == True:
temp = file.readline().strip()
if temp == "":
reading = False
elif temp == "The Forgotten Lands":
expansions.append("The Forgotten Lands (Main Game)")
else:
expansions.append(temp)
game = e.choicebox("Welcome to The Forgotten Lands launcher. Please pick an expansion.","Launcher",choices=expansions)
if game is None:
os._exit(0)
else:
if game == "The Forgotten Lands (Main Game)":
game = "The Forgotten Lands"
dir_path = os.path.dirname(os.path.realpath(__file__))
filepath = (dir_path + "/" + game + "/" + game + ".py")
filepath = filepath.replace("/", "\/")
filepath = filepath.replace("/", "")
subprocess.Popen(filepath, shell=True)
Launch()
它應該是:
subprocess.Popen("python " + filepath, shell=True)
如果那行不通,請問您可以輸入代碼的輸出嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.