python中如何判断一个变量的数据类型?(原创)
2013-06-08 20:06
966 查看
import types
type(x) is types.IntType # 判断是否int 类型
type(x) is types.StringType #是否string类型
.........
--------------------------------------------------------
超级恶心的模式,不用记住types.StringType
import types
type(x) == types(1) # 判断是否int 类型
type(x) == type('a') #是否string类型
type(x) is types.IntType # 判断是否int 类型
type(x) is types.StringType #是否string类型
.........
--------------------------------------------------------
超级恶心的模式,不用记住types.StringType
import types
type(x) == types(1) # 判断是否int 类型
type(x) == type('a') #是否string类型
相关文章推荐
- python中如何判断一个变量的数据类型?(原创)
- python中如何判断一个变量的数据类型
- python中如何判断一个变量的数据类型
- 【Python】判断一个变量的数据类型的两种方法
- python中如何判断变量的数据类型
- Transact-SQL 示例 - 如何获取一个变量的数据类型
- 如何判断一个未知数据类型的数为0
- 变量-数据类型-对象-如何编写python脚本
- Python 判断变量的数据类型
- 如何判断某变量是否为数组数据类型?
- type,isinstance判断一个变量的数据类型
- 如何判断一个变量是数组Array类型
- type,isinstance判断一个变量的数据类型
- 如何判断int、double、float类型数据为0或判断一个未知数据类型的为0或相等
- Python 判断变量的数据类型
- python判断类型:想知道一个对象(实例或者变量)是什么类型,什么结构的
- 如何判断js的变量的数据类型
- python判断类型:想知道一个对象(实例或者变量)是什么类型,什么结构的
- Python【基础:数据类型和变量 字符串和编码 list和tuple 条件判断 循环 dict和set】注意事项(与java,c比较)
- python 判断一个对象的变量类型