【22.2】基本运算
#coding=utf-8 # + - * / % ** // # 赋值运算 = += -= *= /= %= 88= //= 不支持C语言的++ -- #比较运算 == != < > >= < = #逻辑运算 x and y # x or y # not x 结果是True 或者 Flase 注意首字母要大写 #成员运算 in 和 not in a = 10 b = 20 list_demo = [1,2.,3,4,5] if a in list_demo: print ("a 在列表内") elif b not in list_demo: print("b不在列表内") #位运算 按位左移 << 移除的位删掉 移进来的位补0 # 按位右移 >> # 按位与 & # 按位或 | # 按位异或 ^ # 按位取反 ~ c=0b0100010101010 print c print c << 3 d = 7 print d print bin(d) print bin(d<<3) #注意优先级 最好使用() 标识优先运算
浙公网安备 33010602011771号