and、or、not
当and、or左右两边都是表达式的时候,结果是True和False
# 短路问题
# and只要左边是真,继续往后运行;只要左边为假,立即终止运行
4>3 and print('hello world')
4<3 and print('hello world')
# or只要左边是真,立即终止运行;只要左边为假,继续往后运行
4>3 or print('hello world')
4<3 or print('hello world')
# 逻辑运算符,结果不一定是bool类型
# 下面都是进行了隐式的类型转换
print(3and 5and 0and 'hello world') # 0 短路,不往后运行,直接抛出0
print('武汉'and '今天'and '又'and '下雨了') # 下雨了 前面都是真,输出最后一个
print(0 or [] or () or 'zhangsan' or 'ok') # zhangsan zhangsan为真,短路直接抛出zhangsan
print(0 or [] or () or None or 0.0) # 0.0 前面都是假,输出最后一个
'''
:type()
str 字符串
int 整型
float 浮点型
list 列表
tuple 元组
dict 字典
set 集合
0、0.0、空字符串、空列表、空元组、空字典、空集合均会隐式转换为False,其余的则会隐式转换为True。
'''