python中的子进程调用错误
我在子进程调用方面遇到问题 我编写了一个非常简单的代码test.py,它只打印Hello 然后我做了以下工作:python中的子进程调用错误,python,subprocess,call,Python,Subprocess,Call,我在子进程调用方面遇到问题 我编写了一个非常简单的代码test.py,它只打印Hello 然后我做了以下工作: /sw/bin/python2.7 import subprocess call (["test.py"]) 我得到了以下错误: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/sw/lib/python2.7/subprocess.py
/sw/bin/python2.7
import subprocess
call (["test.py"])
我得到了以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/sw/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/sw/lib/python2.7/subprocess.py", line 709, in __init__
errread, errwrite)
File "/sw/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
我可以让它与os.system一起工作,但我渴望学习这个子流程方法。
我哪里做错了
正在调用的test.py位于同一文件夹中。请尝试以下操作:
subprocess.call(["python", "test.py"])
调用[python,test.py]?谢谢GHL。你说得对,its:call[python,test.py]