推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
lucilfer
V2EX  ›  Python

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: inva

  •  
  •   lucilfer · Jan 21, 2019 · 4478 views
    This topic created in 2688 days ago, the information mentioned may be changed or developed.

    这个问题有人遇到过麽?

    # xx.py
    print( urllib.request.urlopen('网页地址,内容是 json 字符串').read() )
    
    
    $ python37 xx.py
    b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\xed[[....
    
    3 replies    2019-01-21 13:08:02 +08:00
    silkriver
        1
    silkriver  
       Jan 21, 2019
    ysc3839
        2
    ysc3839  
       Jan 21, 2019 via Android
    这是 gzip 压缩过的数据,建议使用 requests。
    lucilfer
        3
    lucilfer  
    OP
       Jan 21, 2019
    @ysc3839 谢谢,已经用 requests 解决了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4352 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 00:08 · PVG 08:08 · LAX 17:08 · JFK 20:08
    ♥ Do have faith in what you're doing.