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之禅
行动是绝望的解药!
欢迎转载和引用,但请在明显处保留原文链接和原作者信息!
本博客内容多为个人工作与学习的记录,少数内容来自于网络并略有修改,已尽力标明原文链接和转载说明。如有冒犯,即刻删除!
以所舍,求所得,有所获,方所成。