LoginSignup
1
1

More than 5 years have passed since last update.

python で、 xz ファイルを展開

Posted at

@共用サーバ / pyenv or anaconda が無い環境

もちろん、Python のバージョンは 2系にしてから。

$ pip install --install-option="--prefix=$HOME/share" backports.lzma
# -*- encoding: utf-8 -*-
try:
    import lzma
except:
    import sys
    sys.path.append('/home/bunzaemon/share/lib64/python2.6/site-packages')
    from backports import lzma

with lzma.open("dat.txt.xz") as f:
    print (f.read().decode())
  • 中身は ascii のみ。
  • 2系では、decode() 必要無い。けどあっても動く。
  • 3系ではバイナリなので、decode()必要。
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1