我们在Python中导入this模块,会打印出一段字符串:

翻译对照如下:

The Zen of Python, by Tim Peters

Python的宗旨,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.

尽管一开始那条路可能不是那样明显,除非你是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这个模块是怎么打印出来这段话的,可搜索 【Python this模块的实现方法】

perfcode.com 保留所有权;如需转载,请注明出处。