is 和 == 的区别
生活随笔
收集整理的這篇文章主要介紹了
is 和 == 的区别
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
is 和 == 操作符的區別
python官方解釋:
== 的meaning為equal;
is的meaning為object identity;
is 判斷對象是否相等,即身份是否相同,使用id值判斷; == 判斷對象的值是否相等。 id值是什么? id()函數官網解釋: id(object) Return the “identity” of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id()?value. CPython implementation detail: This is the address of the object in memory. 返回對象的身份,即在對象生命周期中對象保證唯一不變的整數。不重疊的兩個對象可能會有同樣的id值。 對于CPython解釋器:id值是對象在內存中的地址。 ? Cpython是什么? python解釋器用來執行.py文件。從python官網下載并安裝好Python后,我們就直接獲得了一個官方版本的解釋器:CPython。這個解釋器是用C語言開發的,所以叫CPython。在命令行下運行python就是啟動CPython解釋器。CPython是使用最廣的Python解釋器。
?
轉載于:https://www.cnblogs.com/testfan/p/8082447.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的is 和 == 的区别的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MVC与三层架构区别
- 下一篇: strlen和sizeof的长度区别