python中的zipfile
zipfile — Work with ZIP archives
ZipFile.namelist()
Return a list of archive members by name.
返回压缩成员名称列表
ZipFile.getinfo(name)
Return a ZipInfo object with information about the archive member name. Calling getinfo() for a name not currently contained in the archive will raise a KeyError.
根据成员名称获取ZipInfo
ZipFile.infolist()
Return a list containing a ZipInfo object for each member of the archive. The objects are in the same order as their entries in the actual ZIP file on disk if an existing archive was opened.
返回ZipInfo列表
ZipFile.extract(member, path=None, pwd=None)
ZipFile.extractall(path=None, members=None, pwd=None)
解压缩文件,path指定路径(默认为当前路径)
ZipFile.write(filename, arcname=None, compress_type=None)
ZipFile.writestr(zinfo_or_arcname, bytes[, compress_type])
写入, arcname压缩后成员名称
ZipFile.namelist()
Return a list of archive members by name.
返回压缩成员名称列表
with ZipFile('spam.zip', 'r') as myzip: for f in myzip.namelist(): print(f)
ZipFile.getinfo(name)
Return a ZipInfo object with information about the archive member name. Calling getinfo() for a name not currently contained in the archive will raise a KeyError.
根据成员名称获取ZipInfo
ZipFile.infolist()
Return a list containing a ZipInfo object for each member of the archive. The objects are in the same order as their entries in the actual ZIP file on disk if an existing archive was opened.
返回ZipInfo列表
ZipFile.extract(member, path=None, pwd=None)
ZipFile.extractall(path=None, members=None, pwd=None)
解压缩文件,path指定路径(默认为当前路径)
ZipFile.write(filename, arcname=None, compress_type=None)
ZipFile.writestr(zinfo_or_arcname, bytes[, compress_type])
写入, arcname压缩后成员名称
with ZipFile('spam.zip', 'w') as myzip: myzip.write('eggs.txt')
posted on 2014-02-11 23:19 FlowingCloud 阅读(309) 评论(0) 编辑 收藏 举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步