is与==的区别

==是比较运算符,用于比较两个值是否相等,结果返回布尔类型True或False

is操作符是比较值所在的内存地址是否相同,结果返回布尔类型True或False

aList = ['a','b','c']
bList = ['a','b','c']
# True
print(aList == bList)
# False
print(aList is bList)
 
# 1282636127624
print(id(aList))
# 1282636127368
print(id(bList))

扩展补充资料

[Python] is与==的区别https://blog.csdn.net/Hudas/article/details/130461297?spm=1001.2014.3001.5501

你可能感兴趣的:(面试题,python,开发语言)