type() 函数如果你只有第一个参数则返回对象的类型,三个参数返回新的类型对象。
以下是 type() 方法的语法:
type(object) type(<a href="https://www.gaodaima.com/tag/name" title="查看更多关于name的文章" target="_blank">name</a>, bases, dict)
www#gaodaima.com来源gaodaimacom搞#^代%!码网搞代码
参数
name — 类的名称。
bases — 基类的元组。
dict — 字典,类内定义的命名空间变量。
>>> type(1) <type 'int'> >>> type('runoob') <type 'str'> >>> type([2]) <type 'list'> >>> type({0:'zero'}) <type 'dict'>
更多Python知识请关注云海天Python教程栏目。
来源:搞代码网:原文地址:https://www.gaodaima.com