Python裡隱藏的“禪”

來源:互聯網
上載者:User
在 python的lib目錄裡有一個:this.py,它其實是隱藏著一首詩,源碼如下:

代碼如下:

s = """Gur Mra bs Clguba, ol Gvz Crgref

Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Pbzcyrk vf orggre guna pbzcyvpngrq.
Syng vf orggre guna arfgrq.
Fcnefr vf orggre guna qrafr.
Ernqnovyvgl pbhagf.
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
Nygubhtu cenpgvpnyvgl orngf chevgl.
Reebef fubhyq arire cnff fvyragyl.
Hayrff rkcyvpvgyl fvyraprq.
Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.
Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.
Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.
Abj vf orggre guna arire.
Nygubhtu arire vf bsgra orggre guna *evtug* abj.
Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.
Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""

d = {}
for c in (65, 97):
for i in range(26):
d[chr(i+c)] = chr((i+13) % 26 + c)

print "".join([d.get(c, c) for c in s])



輸出結果為:(翻譯自IT柏拉圖)

代碼如下:

The Zen of Python, by Tim Peters
《Python 的禪》 by 提姆·彼特

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!
命名空間是一個讓人尖呼的偉大構想 —— 我們應該在那方面做得更多!


作者果然是很有“濕”意呀!!
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.