Python必会_删除目录文件

阅读 58

2022-11-10


import os
def getListFiles(path):
assert os.path.isdir(path), '%s not exist.' % path
ret = []
for root, dirs, files in os.walk(path):
for filespath in files:
ret.append(os.path.join(root,filespath))
return ret

def remove(file):
for f in file:
print(f)
os.remove(f)

def main():
file= getListFiles('dist/')
print ("file_counter:",len(file))
remove(file)

main()

说明:直接删除,不会放到回收站,慎用。

Python必会_删除目录文件_佐倉


精彩评论(0)

0 0 举报