标签:比较 情况下 包括 列表 技术 字符 pre 没有 png
python中的运算符包括多种多样的,可以分为以下几个大类
3>4 or 4<3 and 1==1 True 1 < 2 and 3 < 4 or 1>2 True 2 > 1 and 3 < 4 or 4 > 5 and 2 < 1 True 1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8 False 1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 False not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 <6 False print(1>2 and 3 or 4 and 3 < 2) == 0
print(int(True)) == 1 print(int(False)) ==0
in,not in : 判断子元素是否在原字符串(字典,列表,集合)中: 例如: #print(‘喜欢‘ in ‘dkfljadklf喜欢hfjdkas‘) #print(‘a‘ in ‘bcvd‘) #print(‘y‘ not in ‘ofkjdslaf‘)
a = 60 # 60 = 0011 1100 b = 13 # 13 = 0000 1101 c = 0 c = a & b; # 12 = 0000 1100 print "Line 1 - Value of c is ", c c = a | b; # 61 = 0011 1101 print "Line 2 - Value of c is ", c c = a ^ b; # 49 = 0011 0001 #相同为0,不同为1 print "Line 3 - Value of c is ", c c = ~a; # -61 = 1100 0011 print "Line 4 - Value of c is ", c c = a << 2; # 240 = 1111 0000 print "Line 5 - Value of c is ", c c = a >> 2; # 15 = 0000 1111 print "Line 6 - Value of c is ", c
标签:比较 情况下 包括 列表 技术 字符 pre 没有 png
原文地址:https://www.cnblogs.com/Arthur7/p/9304627.html