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


source to share





All Articles