找回密码
 立即注册

type和id

2022-2-21 02:33| 发布者: 笨鸟自学网| 查看: 1465| 评论: 0

摘要: type函数返回一个对象的类型。举个例子:print(type('')) # Output: type 'str' print(type()) # Output: type 'list' print(type({})) # Output: type 'dict' print(type(dict)) # Output: type 'type' print(type( ...

type函数返回一个对象的类型。举个例子:

print(type(''))
# Output: <type 'str'>

print(type([]))
# Output: <type 'list'>

print(type({}))
# Output: <type 'dict'>

print(type(dict))
# Output: <type 'type'>

print(type(3))
# Output: <type 'int'>

id()函数返回任意不同种类对象的唯一ID,举个例子:

name = "Yasoob"
print(id(name))
# Output: 139972439030304
上一篇:dir下一篇:inspect模块

Archiver|手机版|笨鸟自学网 ( 粤ICP备20019910号 )

GMT+8, 2025-8-31 00:49 , Processed in 0.016451 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2017 Discuz Team. Template By 【未来科技】【 www.wekei.cn 】

返回顶部