-
运算符 - 算数运算符
+ - * # 加减乘 / # 小数商 // # 整数商 % # 余数 ** # 幂运算(5 ** 3 --> 5 * 5 * 5)
-
运算符 - 增强运算符
# 在算数运算符基础上,增加了为自身赋值的功能 += -= *= /= //= %= **= # data1 += 5 --> data1 = data1 + 5
-
bool 类型操作
bool类型 True(真) False(假) 命题:带有判断性质的陈述句 比较运算符: ==(等于) !=(不等于) > < >= <= 逻辑运算符:判断多个命题之间的关系 # 与(而且) 条件都为“真” 结果 真 print(True and True) # True # 或(或者) 条件都为“假” 结果 假 print(False or False) # False # 非(取反) print(not True)
-
容器通用操作
""" 常用数学运算符 +, += 两个容器中所有元数拼接 *, *= 容器中元数重复 <, > 依次比较两个容器中元数编码值 """ str1 = "悟空" + "八戒" # 悟空八戒 str2 = "悟空" * 2 # 悟空悟空 print("悟空" > "八戒") # Ture """ 常用成员运算符 in 和 not in """ print("悟空" in "悟空八戒") # True print("悟八" not in "悟空八戒") # True