import os
import zipfile
dir = "C://Users//32454//Desktop//4032"
def jieya():
for i in range(4032, 0, -1): # 从4032开始,递减到1
print(i)
file_path = os.path.join(dir, str(i) + ".zip")
if os.path.exists(file_path): # 检查文件是否存在
try:
zpf = zipfile.ZipFile(file_path)
file_list = zpf.namelist() # 得到压缩包里所有文件
for f in file_list:
zpf.extract(f, dir) # 循环解压文件到指定目录,密码
print(str(i) + "解压成功")
except Exception as e:
print(str(i) + "解压失败,原因:" + str(e))
else:
print(str(i) + ".zip文件不存在")
jieya()
标签:脚本,file,python,4032,娃题,str,print,path,zpf From: https://www.cnblogs.com/zhangshuo123/p/18031542