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 · 7812 次点击
    这是一个创建于 3917 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近好多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  
       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 __future__ 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了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5093 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 03:49 · PVG 11:49 · LAX 20:49 · JFK 23:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.