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上就报错。
Return to the fucking manual.