删除前:
删除后:
import os CUR_PATH = r‘C:\Users\shenping\PycharmProjects\Shenping_TEST\day_5\Testfolder‘ def del_file(path): ls = os.listdir(path) for i in ls: c_path = os.path.join(path, i) if os.path.isdir(c_path): del_file(c_path) else: os.remove(c_path) del_file(CUR_PATH)