我正在尝试编写一个Python程序来使用subprocess
执行另一个Python程序。这个程序有什么问题,我怎么能把其他Python程序作为参数?
import sys
import subprocess
def dorun(args):
subprocess.Popen([sys.executable, '%r'] % args)
dorun()
错误是:
najeeb@najeeb:~/Desktop/project$ python new-test.py nmap-test.py
Traceback (most recent call last):
File "new-test.py", line 9, in <module>
dorun()
TypeError: dorun() takes exactly 1 argument (0 given)
答案 0 :(得分:0)
除非您希望能够在一个程序中启动多个程序?
import sys
import subprocess
def dorun(args):
subprocess.Popen([sys.executable, args])
dorun(sys.argv[1])