掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流
id()函數(shù)返回唯一的 id,它顯示對象的標識,并且始終是一個整數(shù)。這種身份對于對象來說是唯一的,并且在其整個生命周期中是不變的。

創(chuàng)新互聯(lián)建站主營瓊中黎族網(wǎng)站建設的網(wǎng)絡公司,主營網(wǎng)站建設方案,成都app開發(fā),瓊中黎族h5小程序設計搭建,瓊中黎族網(wǎng)站營銷推廣歡迎瓊中黎族等地區(qū)企業(yè)咨詢
**id(object)** #Where object can be int, float, str, list, dict, tuple, etc.
id()參數(shù):只接受一個參數(shù)。對象可以是 int、float、str、list、dict、tuple 等類型。
| 參數(shù) | 描述 | 必需/可選 |
|---|---|---|
| 目標 | 需要返回其標識的對象。 | 需要 |
id()方法還返回變量或?qū)ο蟮臉俗R。所有變量和文字值都是對象,因此它們都有不同的id()值。
| 投入 | 返回值 | | 變量或文字 | 唯一的整數(shù)。 |
id()方法的示例id()是如何工作的? class Foo:
b = 5
dummyFoo = Foo()
print('id of dummyFoo =',id(dummyFoo))
輸出:
id of dummyFoo = 140343867415240
print("Id of 10 is: ", id(10))
print("Id of 10.5 is: ", id(10.5))
print("Id of 'Hello World' is: ", id('Hello World'))
print("Id of list is: ", id([1, 2, 3, 4, 5]))
輸出:
Id of 10 is: 8791113061
Id of 10.5 is: 3521776
Id of 'Hello World' is: 60430408
Id of list is: 5466244
num = 10
print("Id of num is: ", id(num))
print("Id of 10 is: ",id(10))
輸出:
Id of i is: 8791113061696
Id of 10 is: 8791113061696 
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流