python中使用types函数判断数据类型,具体方法如下:
1.判断是否是int类型
import types #导入types模块type(x) is types.IntType
import types #导入types模块
type(x) is types.IntType
2.判断是否是string类型
import types #导入types模块type(x) is types.StringType
type(x) is types.StringType
3.判断是否是number类型
import types #导入types模块type(x) is types.NumberType
type(x) is types.NumberType