0
所以我尝试制作一个我正在制作的文本游戏的启动器,并且我需要启动器根据我选择的扩展来运行游戏的一部分。然而,在创建启动器并测试它之后,我意识到一切工作正常,直到启动器应该执行另一个python程序的部分。而不是执行程序,它只是结束,我不知道为什么。这里是我的代码:subprocess.Popen不会运行我的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()
这工作,谢谢! – PHDBanana