热线电话:13121318867

登录
2019-03-29 阅读量: 580
如何在python中类型判断?

如何在python中类型判断?

答:

使用type(obj)来查看obj的类型

type(obj): 返回obj的类型

type(1)      # int 
type(1.0)    # float
type('1')    # str
type(True)   # bool

isinstance(obj,class): 测试对象obj是class的实例

isinstance(1,int)     # True 
isinstance('1',str)   # True

0.0000
6
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子