【python】删除整个文件夹或文件

0.环境

windows
python3.6

1.删除整个文件夹

import shutil
your_want_rm_path = “E:/data/1/”
shutil.rmtree(your_want_rm_path, ignore_errors=True)

2.删除文件

import os
old_file = “E:/data/1/1.txt”
os.remove(old_file)

猜你喜欢

转载自blog.csdn.net/qq_35975447/article/details/110195286