相关疑难解决方法(0)

136
推荐指数
10
解决办法
8万
查看次数

Python 之禅“显式优于隐式”

我不确定这是一个自以为是的问题,还是我误解了“隐式”和“显式”在 Python 上下文中的真正含义。

a = []

# my understanding is that this is implicit
if not a:
   print("list is empty")

# my understanding is that this is explicit
if len(a) == 0:
   print("list is empty")
Run Code Online (Sandbox Code Playgroud)

我正在尝试遵循 Python 规则的禅宗,但我很想知道这是否适用于这种情况,还是我想多了?感谢我能得到的任何指导。

python pep

6
推荐指数
1
解决办法
832
查看次数

标签 统计

python ×2

pep ×1