文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>python中的类型判定

python中的类型判定

时间:2007-04-14  来源:chenhouwu

python中的类型判定有如下几种方法:
(1)>>>print type(1)==int
True
(2)isinstance(1,(int,str))
True
注意,此处第二个参数可以是个tuple,只要第一个参数是其中任何一个类型时,就返回True
(3)import types
>>> int
<type 'int'>
>>> IntType
<type 'int'>
>>> print int is IntType
True
可知,IntType和int是同一类型对象,具有同一object id。
相关阅读 更多 +
排行榜 更多 +
西安交大通

西安交大通

生活实用 下载
长江云通

长江云通

生活实用 下载
translatez

translatez

生活实用 下载