Python之禅
The Zen of Python
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>>
this.py
1 s = """Gur Mra bs Clguba, ol Gvz Crgref 2 3 Ornhgvshy vf orggre guna htyl. 4 Rkcyvpvg vf orggre guna vzcyvpvg. 5 Fvzcyr vf orggre guna pbzcyrk. 6 Pbzcyrk vf orggre guna pbzcyvpngrq. 7 Syng vf orggre guna arfgrq. 8 Fcnefr vf orggre guna qrafr. 9 Ernqnovyvgl pbhagf. 10 Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf. 11 Nygubhtu cenpgvpnyvgl orngf chevgl. 12 Reebef fubhyq arire cnff fvyragyl. 13 Hayrff rkcyvpvgyl fvyraprq. 14 Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff. 15 Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg. 16 Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu. 17 Abj vf orggre guna arire. 18 Nygubhtu arire vf bsgra orggre guna *evtug* abj. 19 Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn. 20 Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn. 21 Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!""" 22 23 d = {} 24 for c in (65, 97): 25 for i in range(26): 26 d[chr(i+c)] = chr((i+13) % 26 + c) 27 28 print "".join([d.get(c, c) for c in s])
Python之禅
相关文章
- Python项目51-课程页面
- 【说站】python中Box-Cox变换是什么
- 【说站】python输入三个数字从小到大排序
- python requests 关闭提示警告
- Python 合并list 11种方式
- Python中用PyTorch机器学习神经网络分类预测银行客户流失模型|附代码数据
- Python 常用外部模块详解
- 图嵌入概述:节点、边和图嵌入方法及Python实现
- python使用最广泛的库介绍
- 【Python】字符串 ⑥ ( 对表达式进行格式化 )
- python 定义异常类
- python-Python与SQLite数据库-使用Python执行SQLite查询(一)
- python三元运算符实现方法
- Python正则表达式的七个使用范例详解