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

我又回来了,tornado 中文 cookie 乱码如何解决??

  •  
  •   dddd · May 27, 2014 · 5784 views
  •   You need to sign in to view this topic
    This topic created in 4544 days ago, the information mentioned may be changed or developed.
    RT,照顾照顾,我毫无经验,遇到问题紧张得要死……
    9 replies  •  2014-05-29 10:07:49 +08:00
    Keyes
    Keyes
    May 27, 2014 via iPhone❤️1
    1
    我保存的是什么?
    我读出来的是什么?
    我显示的是什么?

    里头都是坑,建议楼主研究一下字符编码的问题
    maga
    maga
    May 27, 2014
    2
    建用 print repr(str) 打印出来看是utf-8还是unicode
    dddd
    dddd
    OP
    May 27, 2014❤️1
    3
    @maga 'ç\x82¹ç\x82¹æ»´æ»´'这是什么编码???
    dddd
    dddd
    OP
    May 27, 2014
    4
    @maga 点点滴滴 网页 [utf-8] 上这样显示
    yyfearth
    yyfearth
    May 27, 2014
    5
    cookie 里面为啥要存中文? cookie 存一个Session ID不就可以了么, 其他东西存在Session里面?
    没用过tornado, 不过做其他系统的时候从来不往cookie里面存太多东西
    yemoluo
    yemoluo
    May 27, 2014
    6
    先base64encode 然后放到cookie
    b1074549
    b1074549
    May 27, 2014 via Android
    7
    看tornado源码,主动做encode decode。严格来说header里只允许ASCII字符
    maga
    maga
    May 27, 2014
    8
    @dddd \x82\x81之类utf-8, \u5152之类才是unicode。主动做encode, decode吧
    geew
    geew
    May 29, 2014
    9
    找一个tornado的session或者自己写一个session吧 cookie别存中文
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2399 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 15:35 · PVG 23:35 · LAX 07:35 · JFK 10:35
    ♥ Do have faith in what you're doing.