파이썬에서 초보자 해요, 나는 명령 줄 응용 프로그램을 호출하는 시도를하고 있어요,하지만 실패호출 응용 프로그램은
>>> import subprocess as s
>>> s.call("gpio -g read 17")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/subprocess.py", line 470, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
errread, errwrite)
File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
그러나 나는 shell=True
을 추가하는 경우 모두 작동하기 시작합니다. 왜 누군가가 설명 할 수 있습니까?
>>> import subprocess as s
>>> s.call("gpio -g read 17", shell=True)
>>> 0
"shell = True"를 추가하면 왜 효과가 있습니까? –
'shell = True'의 경우,이 명령은 쉘에 보내지고 쉘은 분할 인수를 분할합니다. – mgilson
@ MarkIngram - 분명히 우리는 동시에 논평했다. – mgilson