我正在尝试使用subprocess.call调用列表时间。它似乎没有工作。任何更好的方式来做到这一点。调用子进程中的列表项
import os, sys
import subprocess as sb
files_to_remove=['*.jpg','*.txt','*.gif']
for item in files_to_remove:
try:
**sb.call(['rm' %s]) %item** # not working
except:
print 'no %s files in directory' %item
子进程调用中双星的用途是什么? –
如果你没有空白,那么问题会更加明显,你也不需要一个子进程来做到这一点 –
建议你看看[这个问题和答案](http:// stackoverflow。 COM /问题/ 6703668 /删除-肯定的 - 文件 - 使用的Python)。 – mshildt