[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