Python基础-所有的数据类型与布尔值的关系

所有的数据类型与布尔值的关系

  • 每一种数据类型,自身的值都有表示True和False的方式
  • not对于一切结果取反
数据类型 为True 为False
int 非0 0
float 非0.0 0.0
str len(str)!=0 len(str)==0即""
list len(list)!=0 len(list)==0即[]
tuple len(tuple)!=0 len(tuple)==0即()
dict len(dict)!=0 len(dict)==0即{}
None not None None

猜你喜欢

转载自blog.csdn.net/Lz__Heng/article/details/130385041