当我使用subprocess使用菜单脚本打开游戏脚本时,我遇到了一个奇怪的错误,即使我尝试重新安装python或pygame,似乎也无法修复。我是不是用错代码了?你知道吗
~信息~ Python版本2.7.6 Pygame Verison 1.9.1版
~给定错误~
> > Traceback (most recent call last): File "C:\Users\Jason\Desktop\Maze\menu.py", line 22, in <module>
> subprocess = Popen(['swfdump', 'main.py', '-d'], stdout=PIPE) File "C:\Python27\lib\subprocess.py", line 709, in __init__
> errread, errwrite) File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
> startupinfo) WindowsError: [Error 2] The system cannot find the file specified
~z~我用的菜单代码~
import pygame
import dumbmenu as dm
pygame.init()
from subprocess import Popen, PIPE
# Just a few static variables
red = 255, 0, 0
green = 0,255, 0
blue = 0, 0,255
size = width, height = 340,240
screen = pygame.display.set_mode(size)
screen.fill(blue)
pygame.display.update()
pygame.key.set_repeat(500,30)
choose = dm.dumbmenu(screen, [
'Start Game',
'Quit Game'], 64,64,None,32,1.4,green,red)
if choose == 0:
pprocess = Popen(['swfdump', 'main.py', '-d'], stdout=PIPE)
stdout, stderr = process.communicate()
elif choose == 1:
pygame.quit()
exit()
对
Popen()
的第一个参数是['swfdump', 'main.py', '-d']
,它将执行 名为swfdump
的东西,带有参数main.py -d
。我怀疑,你想要不同的东西。从the fine documentation:尝试:
看看这样行不行。如果你真的想用一个列表,你可以用
['swfdump main.py -d',]
和shell=False
来代替。你知道吗相关问题 更多 >
编程相关推荐