This article mainly introduces the identity operators in Python, which are the basic knowledge of Python learning. If you need them, refer to the following table to list the identity operators supported by all Python languages.
Example:
The following example shows the identity operators provided by all Python programming languages:
#! /Usr/bin/pythona = 20b = 20if (a is B): print "Line 1-a and B have same identity" else: print "Line 1-a and B do not have same identity" if (id (a) = id (B )): print "Line 2-a and B have same identity" else: print "Line 2-a and B do not have same identity" B = 30if (a is B ): print "Line 3-a and B have same identity" else: print "Line 3-a and B do not have same identity" if (a is not B ): print "Line 4-a and B do not have same identity" else: print "Line 4-a and B have same identity"
When the above program is executed, it will produce the following results:
Line 1-a and B have same identityLine 2-a and B have same identityLine 3-a and B do not have same identityLine 4-a and B do not have same identity