compression - How to use lzma2 in python code? -


i know there module called pylzma. support lzma, not lzma2.

my current solution using subprocess.call() call 7z program.

is there better way?

you can use backports.lzma, see more info: python 2.7: compressing data xz format using "lzma" module

then it's matter of doing e.g.:

from backports import lzma  open('hello.xz', 'wb') f:     f.write(lzma.compress(b'hello', format=lzma.format_xz)) 

or simpler (xz format default):

with lzma.open('hello.xz', 'wb') f:     f.write(b'hello') 

see http://docs.python.org/dev/library/lzma.html usage details.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -