with open (sourcefile,'rb') as i:
with open (targetfile,'wb') as o:
i.seek(0)
s = py7zlib.Archive7z(i)
while True:
tmp = s.read(65536)
if tmp :
o.write(tmp)
continue
else:
break我得到一个错误FormatError:不是7z文件s = py7zlib.Archive7z(i)
当我使用python3.3中的pylzma压缩文件时,它运行在Windows 7上。
我要压缩的文件是一个XML文件。即使这样也没用:
with open (sourcefile,'rb') as i:
with open (targetfile,'wb') as o:
i.seek(0)
s = py7zlib.Archive7z(o)
while True:
tmp = s.read(65536)
if tmp:
o.write(tmp)
continue
else:
break错误:
UnsupportedOperation:读取**引发FormatError(‘不是7z文件’)**
发布于 2014-02-26 14:57:09
您正在XML文件上构建Archive7z,而不是目标文件。
要更正代码:将i替换为s = py7zlib.Archive7z(i)中的o,将s替换为tmp = s.read(65536)中的i。
https://stackoverflow.com/questions/22044139
复制相似问题