==和is之间的区别是python中的运算符。
is和equals(==)运算符大致相同,但不相同。is运算符定义两个变量是否都指向同一对象,而==符号检查两个变量的值是否相同。
范例程式码
# Python program to
# illustrate the
# difference between
# == and is operator
# [] is an empty list
list1 = []
list2 = []
list3=list1
if (list1 == list2):
print("True")
else:
print("False")
if (list1 is list2):
print("True")
else:
print("False")
if (list1 is list3):
print("True")
else:
print("False")输出结果
True False True
热门推荐
10 儿媳买车妈妈祝福语简短
11 伴娘伴郎祝福语简短大方
12 祝福语赠言给老师简短
13 50多岁生日简短祝福语
14 妹妹住院祝福语简短英文
15 导师退休花束祝福语简短
16 四九节气生日祝福语简短
17 新婚过年祝福语大全简短
18 美国老师毕业祝福语简短