簡體   English   中英

格式錯誤:不是 7z 文件

[英]FormatError: not a 7z file

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: not a 7z file s = py7zlib.Archive7z(i)

當我在 Windows 7 上運行的 python 3.3 中使用 pylzma 壓縮文件時。

我試圖壓縮的文件是一個 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: read **raise FormatError('not a 7z file')**

您正在 XML 文件上構建 Archive7z,而不是目標文件。

要糾正你的代碼:代替ios = py7zlib.Archive7z(i)sitmp = s.read(65536)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM