Python中的空值

None

None的数据类型为NoneType,不等于空字符串、空列表,也不等于False

在这里插入图片描述

NaN

“”

" "

判空:not aa is None
def fun():
    return None

a = []
if not a:
    print('S')
else:
    print('F')

if a is None:
    print('S')
else:
    print('F')
# 输出结果为 S F

a为空时,not a表示True
在这里插入图片描述

NoneFalse

运行if Noneif False会得到相同的结果,但结果相同并不代表意义相同,None表示不存在,False表示假
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/WEB___/article/details/127752761
今日推荐