# is # 判断两边数据是否一致且ID一致 # 按住键盘的win+r后输入cmd,进入python的交互模式下 # 会出现对象池存贮问题,因为只有在[-5,256]范围内创建变量使用is才会出现Ture int1 = 123 int2 = 123 int1 is int2 回车 Ture
int1 = 257
int2 = 257
int1 is int2
回车
False
# 在pycharm环境下使用is int1 = 123 int2 = 123 print(int1 is int2) int3 = 300 int4 = 300 print(int3 is int4) 运行后 True True
# is not 与 is 使用方法一样,只是结果不一样
# in # 在指定的序列中找到指定值返回Ture str1 = 'hello boy and girl' print('o' in str1) print('ol' in str1) 运行后 True False