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

关于输出中文 unicode

  •  
  •   ccmao755 · Aug 14, 2015 · 3343 views
    This topic created in 4076 days ago, the information mentioned may be changed or developed.

    flask + pymmsql
    render_template 返回的是([‘中国’,123],[‘深圳’,234]) 这样2个list在一个tuple之中。 那么返回个template的时候(显示明细),我用a[0][0]本来想输出 中国,但是输出的是unicode字符。

    我在jinja2 用decode(utf-8)以及render_template也用decode('utf-8')都是显示的16进制的unicode显示,在console里可以 用print a[0][0] 显示正确的中文。

    请问大家都是如何处理的呢?谢谢! pymssql连接已用utf8连接,py文件也做了utf8的声明。

    clino
        1
    clino  
       Aug 14, 2015
    感觉你发错版了
    ccmao755
        2
    ccmao755  
    OP
       Aug 14, 2015
    哦,是啊,我重新发到flask去了,谢谢提醒
    Livid
        3
    Livid  
    MOD
    PRO
       Aug 17, 2015
    没有问题。这个帖子也为你移动到 /go/python 了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   909 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 19:25 · PVG 03:25 · LAX 12:25 · JFK 15:25
    ♥ Do have faith in what you're doing.