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再附加新文件,貌似内建模块还没有实现直接更新的方法...