[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