【发布时间】:2020-03-14 18:18:17
【问题描述】:
当我使用时
cat folder1/folder2/*_in.txt>>output.txt
直接在终端中,它工作正常。
但是当我从 python 进程内部调用时,它显示错误"No such file or directory":
command = "cat "+path+"*_in.txt >> " + output_variable
print(command) # print exactly the same.
os.system(command) # error : cat: folder1/folder2/*_in.txt: No such file or directory
【问题讨论】:
-
os.system绝对是一个shell -
@Omer,这不是真的。
os.system(something)致电['sh', '-c', something]。sh非常像一个外壳。 -
对,删除了我的误导性评论。
-
为什么使用
os.system()而不是Subprocess模块?