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

python shell 中有关 中文输出的问题

  •  
  •   ljcarsenal · Feb 27, 2014 · 3783 views
    This topic created in 4638 days ago, the information mentioned may be changed or developed.
    >>> s='中文'
    >>> s
    '\xd6\xd0\xce\xc4'
    >>> print s
    中文

    为什么直接s加回车会出现 unicode?
    4 replies  •  1970-01-01 08:00:00 +08:00
    9hills
    9hills
    Feb 27, 2014 via iPad
    1
    你那个s明显不是Unicode...

    S = u"中文" ,这才是unicode
    yakczh
    yakczh
    Feb 27, 2014
    2
    >>> s='中文'
    >>> s
    '中文'
    xierch
    xierch
    Feb 27, 2014
    3
    直接敲 s 是打印 s.__repr__() 的返回值
    7rack
    7rack
    Feb 27, 2014
    4
    print s.encode('utf-8')
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1401 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 16:52 · PVG 00:52 · LAX 08:52 · JFK 11:52
    ♥ Do have faith in what you're doing.