0
這樣確實不錯:蟒子 - 爲什麼引起爭論的空間中的錯誤
import subprocess
subprocess.check_call(["ls","-l"])
,但此行導致錯誤:
>>> subprocess.check_call(["ls"," -l"])
ls: cannot access -l: No such file or directory
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.4/subprocess.py", line 558, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ls', ' -l']' returned non-zero exit status 2
爲什麼會出現這種情況?
在UNIX我可以這樣寫:
ls -l
與ls
和-l
之間有很多的空間我使用Python 3.4.5在CentOS 6
從殼嘗試'〜$「ls」的'-l'' –