0
点赞
收藏
分享

微信扫一扫

Python必会_删除目录文件

知年_7740 2022-11-10 阅读 58


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 条评论