python解压zip文件

时间:2021-06-07 20:42:48   收藏:0   阅读:0
@staticmethod
def unzip_file(failed_file):
zip_file = zipfile.ZipFile(failed_file)
print(zip_file)
if os.path.isdir(failed_file[0:-20]):
pass
else:
os.mkdir(failed_file[0:-20])
for names in zip_file.namelist(): # 解压
zip_file.extract(names, failed_file[0:-20])
zip_file.close()
if os.path.exists(failed_file): # 删除zip文件
os.remove(failed_file)
# print(failed_file[0:-20], ‘解压成功‘)

return failed_file[0:-20]
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!