简体   繁体   English

python 作为密码的禅宗背后是否有特殊的哲学?

[英]Is there a special philosophy behind the zen of python being a cipher?

Before checking this.py I was expecting the Zen of python guidelines and a print statement.在检查this.py之前,我期待python 指南和打印声明的 Zen I found the following instead which consists of a cipher that is translated at runtime when you run import this .我找到了以下内容,它包含一个在运行时在运行时翻译的密码import this Is there a reason behind the string being a cipher rather than the actual text?字符串是密码而不是实际文本背后是否有原因?

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]))

You may find the explanation in Barry Warsaw 2010 blog.您可以在 Barry Warsaw 2010 博客中找到解释。 Link 关联

....Tim or Guido suggested further that we rot13 the contents of the module just for a little extra obfuscation, and we told no one outside our little group.... ....Tim 或 Guido 进一步建议我们 rot13 模块的内容只是为了增加一点混淆,我们不告诉我们小组之外的任何人....

...That was all back in the day when the Python community had a sense of humor... ...这一切都回到了 Python 社区有幽默感的那一天...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM