Mark operators in Python
This article mainly introduces the mark operators in Python, which are the basic knowledge of Python learning. For more information, see
The following table lists the identity operators supported by all Python languages.
Example:
The following example shows the identity operators provided by all Python programming languages:
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 |
#! /Usr/bin/python
A = 20
B = 20
If (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 = 30
If (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:
?
|
1
2
3
4 |
Line 1-a and B have same identity
Line 2-a and B have same identity
Line 3-a and B do not have same identity
Line 4-a and B do not have same identity
|
Note <>: For more exciting tutorials, please pay attention to the help house programming