爲什麼,如果我跑subprocess.check_output('ls')
一切正常,但是當我添加參數的命令,如:subprocess.check_output('ls -la')
我得到錯誤:Python的子命令參數
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/subprocess.py", line 537, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
如何傳遞命令的參數爲subprocess.check_output()
?