推荐学习书目
› 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
wdg8106
V2EX  ›  Python

python2 编码问题请教

  •  
  •   wdg8106 · Dec 12, 2016 · 2737 views
    This topic created in 3582 days ago, the information mentioned may be changed or developed.
    比如一个字符串:
    a = '哈哈'

    解码后 a.decode('utf-8')输出的是:
    u'\u54c8\u54c8'

    但是现在接收到的字符串是 '\u54c8\u54c8' 这种类型的,看起来是 unicode 的字节,但是是 str 类型, 该怎样处理呢
    2 replies  •  2016-12-12 17:10:17 +08:00
    Sylv
        1
    Sylv  
       Dec 12, 2016 via iPhone   ❤️ 4
    '\u54c8\u54c8'.decode('unicode-escape')
    wdg8106
        2
    wdg8106  
    OP
       Dec 12, 2016
    @Sylv 多谢~~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   775 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 20:14 · PVG 04:14 · LAX 13:14 · JFK 16:14
    ♥ Do have faith in what you're doing.