print("eogn" in "hello eogn")
print("e" in "hello eogn")
True
True
print(1 in [1,2,3])
print(‘x‘ in [‘x‘,‘y‘,‘z‘])
True
True
print(‘k1‘ in {‘k1‘:111,‘k2‘:222})
print(111 in {‘k1‘:111,‘k2‘:222})
True
False
print("eogn" not in "hello eogn")
print("e" not in "hello eogn")
False
False
print(1 not in [1,2,3])
print(‘x‘ not in [‘x‘,‘y‘,‘z‘])
False
False
print(‘k1‘ not in {‘k1‘:111,‘k2‘:222})
print(111 not in {‘k1‘:111,‘k2‘:222})
False
True
判断的是id是否相等
如果引用的是同一个对象则返回 True,否则返回 False
x = 1
y = 1
print(x is y)
True
x = 1
y = 2
print(x is y)
False
是判断两个标识符是不是引用自不同对象
如果引用的不是同一个对象则返回结果 True,否则返回 False
x = 1
y = 1
print(x is not y)
False
x = 1
y = 2
print(x is not y)
True
偷懒原则,偷懒到哪个位置,就把当前位置的值返回
10>3 and 10 and None and 10 //返回None
10>3 and 10 and None and 10 or 10 > 3 and 1 == 1 //返回True
原文:https://www.cnblogs.com/j-chao/p/13031607.html