Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

python - Getting error 'NotImplementedError("That compression method is not supported")' when extracting zipfile in python3.9

I have read through the Python documentation about zip files and watched a couple of videos, but everything didn't work. I'm using Kali Linux, so that the password has to be encoded in bytes.

Here is my code, with which I have tried:

import zipfile
import string
import traceback

def try_function(zip, pwd):
    try:
        zip.extractall(pwd=pwd.encode())
        print("Yes")
    except TypeError:
        print("No")


z = zipfile.ZipFile("test.txt.zip")
pwd_local = "abc"

if __name__ == '__main__':
    try_function(z, pwd_local)

But I always get the same error:

Traceback (most recent call last):
  File "ZipWorker.py", line 22, in <module>
    try_function(z, pwd_list)
  File "ZipWorker.py", line 11, in crack
    zip.extractall(pwd.encode())
  File "/usr/lib/python3.9/zipfile.py", line 1633, in extractall
    self._extract_member(zipinfo, path, pwd)
  File "/usr/lib/python3.9/zipfile.py", line 1686, in _ 
extract_member
    with self.open(member, pwd=pwd) as source, 
  File "/usr/lib/python3.9/zipfile.py", line 1559, in open
    return ZipExtFile(zef_file, mode, zinfo, pwd, True)
  File "/usr/lib/python3.9/zipfile.py", line 797, in __init__
    self._decompressor = _get_decompressor(self._compress_type)
  File "/usr/lib/python3.9/zipfile.py", line 698, in 
_get_decompressor
    _check_compression(compress_type)
  File "/usr/lib/python3.9/zipfile.py", line 678, in 
_check_compression
    raise NotImplementedError("That compression method is not 
supported")
  NotImplementedError: That compression method is not supported

Does anyone know how to do this? I'm using python3.9.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...