def unzip(content):
content = content.split()
if len(content) < 2:
return unzipAll(''.join(content))
else:
if len(content) == 3:
extractTo = content[-1]
else:
extractTo = 0
try:
zipFile = zipfile.ZipFile(content[1])
if extractTo == 0:
zipFile.extract(content[0])
else:
zipFile.extract(content[0], extractTo)
zipFile.close()
return []
except FileNotFoundError:
return ['1f401268File %r Not Found' %(content[1])]
except zipfile.BadZipFile:
return ['1f401268File %r is not a zip file' %(content[1])]
except KeyError:
return ['1f401268There no item named %r in the archive' %(content[0])]
except:
return ['Something went wrong when trying to unzip file %r' %(content[1])]
评论列表
文章目录