# 运算符 5大类
# 算术运算符+, -, *, /, %
# 模运算 取余运算
a = 4
print(a % 3)
# 赋值运算符 =, +=, -=
a = 5
a += 1 # a = a + 1
# 比较运算符 >, >=, <, <=, !=, ==, 6种比较关系
# 比较返回的值是布尔值 Ture/False
a = 10
b = 5
print(a >= b)
print(a == b)
print("get" == "GET") # False, python 区分大小写
print("get".upper() == "GET") # print("get".upper() == "Get".lower())
# 逻辑运算符 and, or, not
# 逻辑返回的值是布尔值 Ture/False
a = 10
b = 5
print(a > 11 and b > 6) # F, and 的左右两边结果都为真才为真, 只有一个假就为假
print(a > 11 or b > 3) # T, or 的左右两边结果都为假才为假, 只有一个真就为真
# 成员运算符 in, not in
# 返回的值是布尔值 Ture/False
s = "hello"
h = [1, 3, 5]
d = {"type": "运算符", "name": "operator"}
print('o' in s) # T
print('o' not in s) # F
print(3 in h) # T
print("type" in d) # T,判断Key
网友评论