标签:运算符 返回 操作 pre bool tab 定义 lang and
操作符 | 操作定义 |
---|---|
x and y | 如果x为假,返回x,否则返回y |
x or y | 如果x为真,返回x,否则返回y |
not x | 如果x为假,返回真,否则返回假 |
例子
a = 1
b = 2
c = a and b
print(c)
# 2
a = 0
b = 2
c = a and b
print(c)
# 0
a = 1
b = 2
c = a or b
print(c)
# 1
a = 0
b = 2
c = a or b
print(c)
# 2
a = 1
c = not a
print(c)
# False
标签:运算符 返回 操作 pre bool tab 定义 lang and
原文地址:https://www.cnblogs.com/moyutime/p/14320907.html