我有以下Python代码来删除目录中的文件.由于某种原因,我的.svn目录未被识别为目录.
我得到以下输出:
.svn不是dir
任何想法,将不胜感激.
def rmfiles(path, pattern):
pattern = re.compile(pattern)
for each in os.listdir(path):
if os.path.isdir(each) != True:
print(each + " not a dir")
if pattern.search(each):
name = os.path.join(path, each)
os.remove(name)
Run Code Online (Sandbox Code Playgroud)