我们在Python交互式解释器中输入importthis,就可以看到Python之禅的内容。 Python之禅最早由TimPeters在Python邮件列表中发表,它包含了影响Python编程语言设计的19条软件编写原则。 今天我试着翻译了一下,相对简洁,有利于记忆,希望能帮助到大家。常规翻译 以下是Python之禅的中文翻译: ZenofPython(Python之禅) Beautifulisbetterthanugly。 优美好过丑陋。 Explicitisbetterthanimplicit。 显明好过晦涩。 Simpleisbetterthancomplex。 简单好过复杂。 Complexisbetterthancomplicated。 复杂好过繁杂。 Flatisbetterthannested。 扁平好过嵌套。 Sparseisbetterthandense。 稀疏好过密集。 Readabilitycounts。 计较可读性。 Specialcasesaren’tspecialenoughtobreaktherules。 特殊情况也没有特殊到可以违反这些规则。 Althoughpracticalitybeatspurity。 尽管现实会打击这种单纯。 Errorsshouldneverpasssilently。 异常不应该被默默跳过。 Unlessexplicitlysilenced。 除非被明确噤声。 Inthefaceofambiguity,refusethetemptationtoguess。 面对模棱两可,不要试图猜测。 Thereshouldbeoneandpreferablyonlyoneobviouswaytodoit。 应该有一种,而且不如说唯一一种,明显的解决方案。 Althoughthatwaymaynotbeobviousatfirstunlessyou’reDutch。 尽管一开始并不明显,毕竟你不是那个荷兰人〔Python之父GuidovanRossum〕。 Nowisbetterthannever。 现在行动好过从未开始。 Althoughneverisoftenbetterthanrightnow。 即便从未开始常常好过一拍脑袋。 Iftheimplementationishardtoexplain,it’sabadidea。 如果这个实现难以讲解,这就是一个坏思路。 Iftheimplementationiseasytoexplain,itmaybeagoodidea。 如果这个实现易于讲解,这或许是一个好想法。 Namespacesareonehonkinggreatidealet’sdomoreofthose! 命名空间真是一个顶呱呱的绝妙主意,让我们多做一些有关它的事情。我的翻译 TheZenofPython 《蟒之禅》 Beautifulisbetterthanugly。 美胜丑。 Explicitisbetterthanimplicit。 显胜隐。 Simpleisbetterthancomplex。 简胜繁。 Complexisbetterthancomplicated。 繁胜杂。 Flatisbetterthannested。 平胜叠。 Sparseisbetterthandense。 稀胜稠。 Readabilitycounts。 术欲显。 Specialcasesaren’tspecialenoughtobreaktherules。 不逾矩, Althoughpracticalitybeatspurity。 实难完。 Errorsshouldneverpasssilently。 无忽过, Unlessexplicitlysilenced。 可漏愆。 Inthefaceofambiguity,refusethetemptationtoguess。 拒疑数。 Thereshouldbeoneandpreferablyonlyoneobviouswaytodoit。 取法一, Althoughthatwaymaynotbeobviousatfirstunlessyou’reDutch。 择于多。 Nowisbetterthannever。 贵现行, Althoughneverisoftenbetterthanrightnow。 纵多蹶。 Iftheimplementationishardtoexplain,it’sabadidea。 陋难陈, Iftheimplementationiseasytoexplain,itmaybeagoodidea。 佳易言。 Namespacesareonehonkinggreatidealet’sdomoreofthose! 定名属。