code:
def boolean_study():
a = None
b = ''
c = 0
d = {}
e = []
f = ()
if a:
print('i am None')
elif b:
print('i am empty str')
elif c:
print('i am 0')
elif d:
print('i am empty obj or empty dic')
elif e:
print('i am empty array or list')
elif f:
print('i am empty tuple')
else:
print('a, b, c, d, e and f is False')
boolean_study()
result:
a, b, c, d, e and f is False
举一反三: javascript、 typescript 也类似
版权声明:本文为weixin_47503016原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。