推荐学习书目
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 · 3462 views
    This topic created in 4484 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
        1
    9hills  
       Feb 27, 2014 via iPad
    你那个s明显不是Unicode...

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