python里怎么查看数据类型

 

python里怎么查看数据类型?

python里可以通过type()函数来查看数据类型。

Python 内置函数 Python 内置函数

Python type() 函数如果你只有第一个参数则返回对象的类型,三个参数返回新的类型对象。

  

如果要判断两个类型是否相同推荐使用 isinstance()。

以下是 type() 方法的语法:

  

参数

name:类的名称。

bases:基类的元组。

dict:字典,类内定义的命名空间变量。

返回值

一个参数返回对象类型, 三个参数,返回新的类型对象。

实例

以下展示了使用 type 函数的实例:

  

type() 与 isinstance()区别:

  

以上就是python里怎么查看数据类型的详细内容

猜你喜欢

转载自www.cnblogs.com/IT-SUJIU/p/11737535.html
今日推荐