py:你可以用` if x is not None`

ref

https://blog.csdn.net/sasoritattoo/article/details/12451359

note

代码中经常会有变量是否为None的判断,有三种主要的写法:

第一种是if x is None

第二种是 if not x:

第三种是if not x is None(这句这样理解更清晰if not (x is None)) 。

发布了226 篇原创文章 · 获赞 35 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/paulkg12/article/details/105225350