我尝试通过套接字使用子进程(python 2.7 (qpython android))发送命令。代码如下:
#reponse is my command
x = subprocess.Popen(reponse,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
y = str(x.stdout.read() + x.stderr.read())但是当我尝试的时候,我得到了这个错误:
Traceback (most recent call last):
File "ser.py", line 72, in <module>
stdin=subprocess.PIPE)
File "/QPython/QPython2-core/build/python-install/lib/python2.7/subprocess.py",
line 679, in __init__
File "/QPython/QPython2-core/build/python-install/lib/python2.7/subprocess.py",
line 1228, in _execute_child
OSError: [Errno 2] No such file or directory那么,谁能告诉我哪里出了问题,以及如何解决这个问题..提前寻求帮助。
发布于 2017-05-04 21:01:51
我发现如果指定shell=True,命令就不起作用。我也犯了同样的错误。
您应该以列表形式使用命令及其参数;即:
your_cmd = ['examplecmd', '-a', 'foo', '-b', 'bar']https://stackoverflow.com/questions/42684131
复制相似问题