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
totoismi
V2EX  ›  Python

zen of python in Simplified Chinese

  •  
  •   totoismi ·
    vincentping · 2014-10-11 10:04:18 +08:00 · 3341 次点击
    这是一个创建于 3484 天前的主题,其中的信息可能已经有所发展或是发生改变。
    国庆在家没事,看到python中的import this挺好玩,打开this.py,里面做了些加密。

    学习了下,模仿写了个中文版pythis.py,大家看看能不能用。

    安装:
    pip install pythis

    运行:
    python中:
    import pythis

    有什么问题,请指出,呵呵!
    10 条回复    2014-10-14 20:23:24 +08:00
    phuslu
        1
    phuslu  
       2014-10-11 11:08:00 +08:00
    sys.setdefaultencoding('utf-8') 这一句影响全局,差评,呵呵。
    phuslu
        2
    phuslu  
       2014-10-11 11:11:17 +08:00
    EIBTI 推荐翻译是 "明言胜于暗示"
    limbo0
        3
    limbo0  
       2014-10-11 11:13:18 +08:00
    # -*- coding=utf-8 -*-
    为什么还要加sys.setdefaultencoding('utf-8') 啊
    totoismi
        4
    totoismi  
    OP
       2014-10-11 12:01:30 +08:00
    @limbo0
    呵呵,原来写CGI的时候出过编码问题,所以习惯性加上了,已经删除,谢谢!
    @phuslu
    谢谢指正。翻译我是直接借用了赖勇浩的翻译,保证完整性,就不改了。
    NCE
        5
    NCE  
       2014-10-11 17:31:09 +08:00
    貌似
    # -*- coding=utf-8 -*-
    后还是有必要加sys.setdefaultencoding('utf-8') 的

    不然操作数据会有问题。

    起码我用cmd执行脚本是有问题的。
    yxzblue
        6
    yxzblue  
       2014-10-11 19:00:47 +08:00
    1楼,没看错的话是GoAgent作者啊,膜拜感谢大神
    totoismi
        7
    totoismi  
    OP
       2014-10-11 21:15:06 +08:00
    请问@NCE 你是什么系统下,PYTHON版本是?CMD下有什么问题呢?
    leeoo
        8
    leeoo  
       2014-10-12 12:48:33 +08:00   ❤️ 1
    Python 3.4.1下执行报错~
    totoismi
        9
    totoismi  
    OP
       2014-10-12 15:46:25 +08:00   ❤️ 1
    @leeoo 已经修复。python3下unichr()报错,直接用chr()即可。谢谢!
    leeoo
        10
    leeoo  
       2014-10-14 20:23:24 +08:00
    @totoismi
    感谢,刚在Python 3.4.1下执行成功!:D
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2787 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:44 · PVG 23:44 · LAX 08:44 · JFK 11:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.