is
and
= =
difference
/difference between IS and = =
For Python objects, there are id/type/value three characteristics, and in judging two equal is and = =, respectively, the object ID and value are judged, the following example can see the difference between the two,
1x = [1, 2, 3]2y = [1, 2, 3]3z =x4 Print('x ID is%d, y id was%d, z ID is %d'%(ID (x), id (y), id (z) ))5 #x ID is 52275016, y id was 13096648, z ID is 522750166 7 #is judge by id, = = Judge by value8 Print(x isY, X==y)#False, True9 Print(x isZ, x==z)#true, True
From the view of the results, X and Y values are the same, but the ID is different, and the values of x and Z are the same, that is, the two points to the same object, respectively, Y and Z and x equivalent comparison, the results can be seen, the ID of the same x and Z are statements, and the ID is different but the same value of
Reference links
http://blog.csdn.net/imzoer/article/details/8637408
Python_tips[6], is and = = = Difference