Python 中常见的内置类型 (built-in type)

对象的三个特征

身份、类型 和 值

id()
type()

>>> string = 'hello world'
>>> id(string)
4388768264
>>> type(string)
<class 'str'>

常见的内置类型

  • None (全局只有一个): 在 Python 解释器中存在且只存在唯一的一个 None 对象
>>> a = None
>>> b = None
>>> id(a) == id(b)
True
  • 数值类型:
    int
    float
    complex
    bool

  • 迭代类型

  • 序列类型
    list
    bytes bytearray memeoryview (二进制序列)
    range
    tuple
    str
    array

  • 映射类型
    dict

  • 集合
    set
    frozenset

  • 上下文管理类型
    with statement

  • 其他
    模块类型
    类和实例
    函数类型
    方法类型
    代码类型
    object 对象
    type 类型
    ellipsis 类型
    notimnotimpleted

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。