# make a program to extract zip file import os import zipfile import shutil # 找到此目录下的所有zip文件,并解压到此目录· def extract_file(file_path): # print(file_path) # 开始循环走file_path for root, dirs, files in os.walk(file_path): for file in files: # print(file) if file.endswith('.zip'): # print(file) # 解压文件 zip_file = zipfile.ZipFile(os.path.join(root, file)) # print(zip_file) zip_file.extractall(file_path) zip_file.close() # # 删除文件夹里的文件夹 for root, dirs, files in os.walk(file_path): for dir in dirs: shutil.rmtree(os.path.join(root, dir))```
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)