Python 3其实挺好的,2下面的'ascii' codec can't encode character问题瞬间解决,我直接学3啦 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
tedd
V2EX    Python

Python 3其实挺好的,2下面的'ascii' codec can't encode character问题瞬间解决,我直接学3啦

  •  
  •   tedd 2013-08-02 22:21:18 +08:00 8332 次点击
    这是一个创建于 4526 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近好多Python新书都是用Python 3,是时候啦,请问现在还有什么只能在2下面才能做的吗
    17 条回复    1970-01-01 08:00:00 +08:00
    sillyousu
        1
    sillyousu  
       2013-08-02 22:23:38 +08:00   1
    应该说有哪些库是只支持Py2的:
    http://python3wos.appspot.com/

    自备梯子
    ushuz
        2
    ushuz  
       2013-08-02 22:43:39 +08:00
    Unicode还有许多坑在前面等着你,加油!
    tioover
        3
    tioover  
       2013-08-02 22:59:02 +08:00
    看了一下 @sillyousu 的页面,除了supervisor 有点要命以外就没什么了
    thedevil5032
        4
    thedevil5032  
       2013-08-03 08:03:20 +08:00 via iPad
    关键看你需要什么库。

    我之前一直只用 Python Standard Library 和 PyQt,Python 3 完全没问题。

    现在学 Python 的 Web 框架,Flask,还是老老实实用 Python 2。
    wuxqing
        5
    wuxqing  
       2013-08-03 08:39:41 +08:00
    新版的Flask好像是支持py3的
    raptor
        6
    raptor  
       2013-08-03 11:28:31 +08:00
    @thedevil5032 bottle支持py3
    thedevil5032
        7
    thedevil5032  
       2013-08-03 11:36:11 +08:00 via iPad
    @wuxqing 请仔细阅读文档。
    http://flask.pocoo.org/docs/advanced_foreword/#the-status-of-python-3
    咩。简单说,支持,但是官方强烈推荐 Python 2。

    @raptor 这个我是知道的,但还是谢谢你。
    sandtears
        8
    sandtears  
       2013-08-03 12:47:14 +08:00
    基本上私的习惯是,所有字符串开始就定义成utf-8,需要输出的时候或者编码的时候才会encode
    Muninn
        9
    Muninn  
       2013-08-03 15:10:57 +08:00
    从今年开始 绝大多数都支持py3了
    shiny
        10
    shiny  
    PRO
       2013-08-03 15:13:03 +08:00   1
    用了 python3 后编码问题几乎很少遇到了。
    用了 node js 后 python 异步编程里的大多数困扰的问题几乎没遇到了。
    funagi
        11
    funagi  
       2013-08-03 16:40:13 +08:00
    from __fture__ import unicode_literals

    可解否?
    wodemyworld
        12
    wodemyworld  
       2013-08-03 18:46:32 +08:00
    全面发动第三次世界大战,最后统一为一个国家一个民族,然后编码的问题就再也不是问题了
    ushuz
        13
    ushuz  
       2013-08-03 19:51:19 +08:00
    @funagi 看到有人说即使加了 import unicode_literal,标准库和第三方库的返回未必是unicode。
    clowwindy
        14
    clowwindy  
       2013-08-03 20:30:43 +08:00 via iPhone
    除了检测用户名合法性的时候,不用 unicode,只用 str 路过
    reus
        15
    reus  
       2013-08-04 09:56:32 +08:00 via Android   1
    真正理解unicode及其编码,用py2也没啥问题。不理解的,py3也救不了你
    angelface
        16
    angelface  
       2013-08-04 10:18:51 +08:00
    @reus 说的真好, 那么多用py2的, 也一样用的也好好的;
    Ever
        17
    Ever  
       2013-08-04 10:21:17 +08:00
    python3不就把python2的unicode改成str, 把python2的str改成bytes么, 用法上又没什么实质变化


    @thedevil5032 'We strongly recommend using Python 2.6 and 2.7 with activated Python 3 warnings during development.' 是建议你开发用python2的时候打开python3的警告, 写起来注意可以减少以后迁移到python3的麻烦, 你怎么解读成建议你用python2了
    关于     帮助文档     自助推广系统 &nbs;   博客     API     FAQ     Solana     1181 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 17:40 PVG 01:40 LAX 09:40 JFK 12:40
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86