【发布时间】:2013-02-08 17:23:18
【问题描述】:
我正在尝试在 Popen 中运行此 BASH 命令:
find /tmp/mount -type f -name "*.rpmsave" -exec rm -f {} \;
但每次我得到: “查找:缺少 `-exec'\n 的参数”在标准错误中。
python 相当于什么?
我的幼稚做法是:
for (root,files,subdirs) in os.walk('/tmp/mount'):
for file in files:
if '.rpmsave' in file:
os.remove(file)
肯定有更好、更 Python 的方式来做这件事吗?
【问题讨论】: