Archive with error opening (7z) in python while creating 7zip

I am learning python got the basics

to make it better, I tried to create a program to open archive files, not just open.

I can easily create and open 7z files, however when the archive is created with 7zip it does not open it, does anyone know why and how I can open the files created by 7zip

  data = b"Insert Data Here"
  with lzma.open("file.7z", "w") as f:
    f.write(data)


  with lzma.LZMAFile("file.7z") as f:
        fc =f.read()
        print(fc)

      

tracing

Traceback (most recent call last):
  File "<string>", line 420, in run_nodebug
  File "C:\Users\<name>\Documents\Py\decompression.py", line 20, in <module>
    main()
  File "C:\Users\<name>\Documents\Py\decompression.py", line 15, in main
    fc =f.read()
  File "C:\Python33\lib\lzma.py", line 291, in read
    return self._read_all()
  File "C:\Python33\lib\lzma.py", line 244, in _read_all
    while self._fill_buffer():
  File "C:\Python33\lib\lzma.py", line 238, in _fill_buffer
    self._buffer = self._decompressor.decompress(rawblock)
_lzma.LZMAError: Input format not supported by decoder

      

+3
python python-3.x compression 7zip lzma


source to share


No one has answered this question yet

Check out similar questions:

5116
How can I check if a file exists without exceptions?
2112
How do I copy a file in Python?
2028
How to read a file line by line in a list?
1043
Find all files in directory with .txt extension in Python
989
If Python is interpreted, what are .pyc files?
597
Twitter image encoding problem
585
open () in Python doesn't create a file if it doesn't exist
399
How do I open multiple files using "open" in Python?
1
Testing 7-Zip archives from python script
1
Kivy-Python error after releasing VideoCapture (0) and setting kivy camera.play = True



All Articles
Loading...
X
Show
Funny
Dev
Pics