==和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 生日祝福语短句简短霸气
14 生日祝福语简短蛋糕上
15 怎样给人送祝福语简短
16 幼儿节日祝福语大全简短
17 给老师祝福语简短元旦
18 朋友领证祝福语长文简短