subprocess.Popen('start') 失败
在Python中运行这个会出现一个Windows错误,提示找不到指定的文件。
失败的情况:
import subprocess
subprocess.Popen('start notepad.exe')
在命令窗口中,这个是可以正常工作的。
start notepad.exe
我猜这可能是路径的问题,Windows找不到start[.exe?]这个文件。这个文件在哪里,我可以把它添加到路径中,或者直接在Popen调用中包含它。
谢谢。
2 个回答
-1
notepad = subprocess.Popen(r'start "" "C:\1.txt"', shell=True)
time.sleep(3)
print(notepad.pid)
当然可以!请把你想要翻译的内容发给我,我会帮你把它变得更简单易懂。
13
我不太确定 start
是一个程序。我觉得它可能是CMD命令行的一个内置命令。你可以试试:
subprocess.Popen('cmd /c start notepad.exe')
另外,有没有什么特别的原因不直接使用:
subprocess.Popen('notepad.exe')