舉例講解Python中的身份運算符的使用方法
更新時間:2015年10月13日 15:47:05 投稿:goldensun
這篇文章主要介紹了舉例講解Python中的身份運算符的使用方法,是Python入門學(xué)習(xí)中的基礎(chǔ)知識,需要的朋友可以參考下
Python身份運算符
身份運算符用于比較兩個對象的存儲單元

以下實例演示了Python所有身份運算符的操作:
#!/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"
以上實例輸出結(jié)果:
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
相關(guān)文章
Windows安裝Anaconda并且配置國內(nèi)鏡像的詳細教程
我們在學(xué)習(xí) Python 的時候需要不同的 Python 版本,關(guān)系到電腦環(huán)境變量配置換來換去很是麻煩,所以這個時候我們需要一個虛擬的 Python 環(huán)境變量,這篇文章主要介紹了Windows安裝Anaconda并且配置國內(nèi)鏡像教程,需要的朋友可以參考下2023-01-01
Python爬蟲eval實現(xiàn)看漫畫漫畫柜mhgui實戰(zhàn)分析
這篇文章主要為大家介紹了Python爬蟲eval實現(xiàn)看漫畫漫畫柜mhgui實戰(zhàn)分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-07-07
TensorFlow深度學(xué)習(xí)之卷積神經(jīng)網(wǎng)絡(luò)CNN
這篇文章主要介紹了TensorFlow深度學(xué)習(xí)之卷積神經(jīng)網(wǎng)絡(luò)CNN2018-03-03
終于搞懂了Keras中multiloss的對應(yīng)關(guān)系介紹
這篇文章主要介紹了終于搞懂了Keras中multiloss的對應(yīng)關(guān)系介紹,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-06-06
python操作excel的方法(xlsxwriter包的使用)
這篇文章主要為大家詳細介紹了python操作excel的方法,xlsxwriter包的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-06-06

