''' == The equality of the test value is the consistency of the test object, that is, the same memory address ''' l1=[ 1 ,( 'a' , 3 )] l2=[ 1 ,( 'a' , 3 )] print (l1==l2) #l1 and l2 are equal True print (l1 is l2) #l1 and l2 are not the same object False print ( id (l1), id (l2)) #2272260557320 2272260585160 s1= 'spam' s2= 'spam' print (s1==s2) #s1 and s2 are equal True print (s1 is s2) #s1 and s2 are the same object True print ( id (s1), id (s2)) #2658123313368 2658123313368
python == and is
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326000476&siteId=291194637
Recommended
Ranking