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)) 。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章