【发布时间】:2013-08-25 09:12:11
【问题描述】:
大家好,我想删除特定文件夹中的所有文件/文件夹,为此我编写了以下代码:(我想删除保存在 co_directory 中的目录中的所有文件/文件夹,packages_with_.... txt 文件,但是我得到一个错误
def remove_file():
remove="sudo rm -rf !(packages_with_diff_branches.txt|packages_with_same_branches.txt)"
p = subprocess.Popen("""
%s
%s""" % (co_directory,remove),shell=True , executable='/bin/bash')
p.wait()
/bin/bash: -c: line 3: syntax error near unexpected token `('
/bin/bash: -c: line 3: ` sudo rm -rf !(packages_with_diff_branches.txt|packages_with_same_branches.txt)'
有人帮我吗?非常感谢
编辑 **co_directory 是全局变量**
【问题讨论】:
标签: python terminal command subprocess