ตัวดำเนินการเอกลักษณ์ของ Python
ตัวดำเนินการเอกลักษณ์ของ Python
ตัวดำเนินการข้อมูลประจำตัวใช้เพื่อเปรียบเทียบอ็อบเจ็กต์ ไม่ใช่ว่าเท่ากัน แต่ถ้าเป็นอ็อบเจ็กต์เดียวกันจริง ๆ โดยมีตำแหน่งหน่วยความจำเดียวกัน:
Operator | Description | Example | Try it |
---|---|---|---|
is | Returns true if both variables are the same object | x is y | |
is not | Returns true if both variables are not the same object | x is not y |