在MAC上使用python的subprocess模块的问题?
import subprocess
def killpid():
cmd = ["adb", "shell", "ps"]
# print cmd
run_cmd = subprocess.Popen(cmd, stdout=subprocess.PIPE)
print run_cmd.stdout.read()
if __name__ == '__main__':
killpid()
运行结果提示:
['adb', 'shell', 'ps']
Traceback (most recent call last):
File "/Users/***/test1.py", line 30, in <module>
killpid()
File "/Users/***/test1.py", line 11, in killpid
run_cmd = subprocess.Popen(cmd, stdout=subprocess.PIPE)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
[Finished in 0.049s]
这段代码在Windows上运行没有问题,但在MAC上就报错。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Return to the fucking manual.