继续挑战,轻松一下
第23题地址bonus.html
- 网页标题是
what is this module?
,题目内容为空,源码有好多隐藏信息:<!– TODO: do you owe someone an apology? now it is a good time to tell him that you are sorry. Please show good manners although it has nothing to do with this level. –>
<!– it can’t find it. this is an undocumented module. –>
<!– ‘va gur snpr bs jung?’ –>
首先是这个TODO
,是因为第19题bin.html那封骂人的邮件需要给Leopold道歉,又说跟这题没关系,先不管它了,记下来,可能以后会用到。
然后标题问这是什么模块?
,提示里说找不到,这是一个没有文档的模块
,最后是一段乱码,估计是初级密码学。图片是一头牛。
先是关键要找到问题问的是什么模块。根据模块的特点——没有文档,通过搜索和本机python
库里面查找,发现一个叫this
的模块,简单且没有文档!
import this
print(dir(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!
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'c', 'd', 'i', 's']
我们去看this
的源码this.py,发现this.s
是一长串乱码,this.d
是一个密码字典,将那串乱码翻译成了上面的Python之禅:
Python之禅 最早由 Tim Peters在Python邮件列表中发表,它包含了影响Python编程语言设计的19条软件编写原则。在最初及后来的一些版本中,一共包含20条,其中第20条是“这一条留空(…)请 Guido 来填写“。这留空的一条从未公布也可能并不存在。这些文本属于 公共领域。
Python之禅作为一个信息条款被录入Python增强建议(PEP)的第20条,在Python语言的官方网站也能找到。它还作为复活节彩蛋被包含在Python解释器中。如果输入 import this 就会在Python的编程环境IDLE中显示。
优美优于丑陋,
明了优于隐晦;
简单优于复杂,
复杂优于凌乱,
扁平优于嵌套,
稀疏优于稠密,
可读性很重要!
即使实用比纯粹更优,
特例亦不可违背原则。
错误绝不能悄悄忽略,
除非它明确需要如此。
面对不确定性,
拒绝妄加猜测。
任何问题应有一种,
且最好只有一种,
显而易见的解决方法。
尽管这方法一开始并非如此直观,
除非你是荷兰人。
做优于不做,
然而不假思索还不如不做。
很难解释的,必然是坏方法。
很好解释的,可能是好方法。
命名空间是个绝妙的主意,
我们应好好利用它。From wikipedia.org
这么看来,还剩下的那段乱码有解了:
print(''.join(this.d.get(c, c) for c in 'va gur snpr bs jung?'))
in the face of what?
问题看上去很熟悉。我们在Python之禅里面找到一句:
In the face of ambiguity, refuse the temptation to guess.
我们把地址改为ambiguity.html,来到了下一题!