删除文件夹下的所有文件

CUR_PATH  = r'D:\python_web_pro\QAPlatform\jlc_test_mgmt\upload\process_excel'
# 删除文件夹下所有内容
def rm_file(path):
    ls = os.listdir(path)
    print("===============ls:",ls)
    for i in ls:
        c_path = os.path.join(path,i)
        print("===============c_path:", c_path)
        if os.path.isdir(c_path):
            rm_file(c_path)
        else:
            os.remove(c_path)

rm_file(CUR_PATH)

你可能感兴趣的:(删除文件夹下的所有文件)