专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Perl/Python

pyhthon zipfile获取压缩文件列表后怎样打开其中某个文件?该如何处理

发布时间:2011-06-29 20:11:46 文章来源:www.iduyao.cn 采编人员:星星草
pyhthon zipfile获取压缩文件列表后怎样打开其中某个文件?
如题。似乎ZipFile没有open操作..


zCmfile = zipfile.ZipFile(targetPath,'r')
  for oneFile in zCmfile.namelist():
  if oneFile[:-4] == omcName:
  print oneFile
  #以append方式打开需要写入的文件

------解决方案--------------------
ZipFile.open(name[, mode[, pwd]]) 
Extract a member from the archive as a file-like object (ZipExtFile). name is the name of the file in the archive, or a ZipInfo object. The mode parameter, if included, must be one of the following: 'r' (the default), 'U', or 'rU'. Choosing 'U' or 'rU' will enable universal newline support in the read-only object. pwd is the password used for encrypted files. Calling open() on a closed ZipFile will raise a RuntimeError.

只读而已,如果你要改写嘛要整个解压,修改,再压缩比较费事,或者删掉原来的entry再附加新文件,貌似内建模块还没有实现直接更新的方法...

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: