==和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