python判断数据类型使用什么函数

1252
2021/1/20 10:52:22
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

python判断数据类型使用什么函数

python中使用types函数判断数据类型,具体方法如下:

1.判断是否是int类型

import types #导入types模块

type(x) is types.IntType

2.判断是否是string类型

import types #导入types模块

type(x) is types.StringType

3.判断是否是number类型

import types #导入types模块

type(x) is types.NumberType

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: Python抛出异常和声明异常有什么区别