A pit, don't know why, just record it.
1 while loop! = 0:2 // omit operation 3 print loop4 if loop = = 0:5 print (ID (loop))6 print (ID (0))
Running results in Python 2.7
Skip loop printing with loop not 0
03809311234396768
Running results in Python 3.x
Skip loop printing with loop non 0 0495494208495494208
Loop is iterated (not-1) in the search, such as modulo operations
In the process of iterative operation, loop object has been changing, when loop = = 0, in python 2 appears loop = = 0 but the memory address (ID) of the loop is not equal to the ID of 0
At this point the value of loop is printed in int is 0, and is printed with float 0.0
But the ID (loop) is the not ID (0)
This problem was not encountered in Python 3, the same piece of code, after running to loop = = 0 in 3, id (loop) = = ID (0)
For the time being, don't know why, just record it.
[Python Basics] Python 2 is different from Python 3, an unknown pit about objects