zen of python什么意思_The Zen of Python翻译

本文介绍了Python之禅的内容,强调了简洁、清晰及可读性的重要性,并提倡遵循显而易见的编程方式。文中还提到了一些Python编程的基本原则,如错误处理、命名空间等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Paste_Image.png

Python之禅 (translated by Mike

美丽胜于丑陋

明确胜于模糊

简单胜于复杂

扁平胜于嵌套

稀疏胜于稠密

可读性重要

特殊性不应破坏基本规则

虽然实用性比简洁的代码中啊哟

不能让错误无声通过

除非错误本身无声

面对歧义拒绝猜测

应当有一个并且优先选择一个显而易见的方式去处理

虽然这种方式在最开始不是显而易见的

除非你提早明白

这样做总比不做好

虽然不做常常比现在要好

如果你的实现很难去解释,那么这不是一个好的方式

如果你的实现很容易去解释,那么这可能是一个好的方式

命名空间是一个非常好的东西,让我们多去使用

@紫牛的翻译 原文:http://article.yeeyan.org/view/58498/154430

The Zen of Python

Python 之禅

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!

名可名, 请常名

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值