代码中经常会有变量是否为None的判断,有三种主要的写法:第一种是if x is None;第二种是 if not x:;第三种是if not x is None(这句这样理解更清晰if not (x is None)) 。
在python中 None, False, 空字符串””, 0, 空列表[], 空字典{}, 空元组()都相当于False ,即:not None == not False == not ‘’ == not 0 == not [] == not {} == not ()
https://www.cnblogs.com/lincappu/p/8305763.html
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。









评论