Python and or 表达式的值


v1 = "YoungCyan"
v2 = "LiLei"
temp = v1 and v2

#第一步 将and前后的值装换为布尔值, 这里是 True and True
#第二部 判断本次操作谁能最终确定整个表达式真假,就返回谁做表达式的值。这里影响这个表达式的真假值是v2
#所以temp == v2;
#or表达式的推理也是如此

print(temp)

v1 = ""    #bool值为false
v2 = "YoungCyan"
temp = v1 and v2

print(temp + "<========== '空字符串'")

v1 = ""    #bool值为false
v2 = "YoungCyan"
temp = v2 and v1

print(temp + "<========== '空字符串'")

print("==================================================")
print("or 表达式")

v1 = ""    #bool值为false
v2 = "YoungCyan"
temp = v1 or v2

print(temp)
v1 = ""    #bool值为false
v2 = "YoungCyan"
temp = v2 and v1

print(temp+"<======'空字符串'")

v1 = ""    #bool值为false
v2 = 0
temp = v2 and v1
print(temp)