当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 一个参数实例
>>> type(1)
<type 'int' >
>>> type( 'school' )
<type 'str' >
>>> type([2])
<type 'list' >
>>> type({0: 'zero' })
<type 'dict' >
>>> x = 1
>>> type( x ) == int # 判断类型是否相等
True
# 三个参数
>>> class X(object):
... a = 1
...
>>> X = type( 'X' , (object,), dict(a=1)) # 产生一个新的类型 X
>>> X
< class '__main__.X' >
|
type() 与 isinstance()区别:
1 2 3 4 5 6 7 8 | class A:
pass
class B(A):
pass
isinstance(A(), A) # returns True
type(A()) == A # returns True
isinstance(B(), A) # returns True
type(B()) == A # returns False
|
推荐:《python教程》
以上就是python里怎么查看数据类型的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
Python使用当前时间、随机数产生唯一数的方法讲解
Python全栈工程师需要学什么
Python中的列表与元组有什么区别?一文搞懂元组与列表的异同点
Python如何计算时间差
Python绘制五角星
Python文件的后缀名是什么
Python语言是由哪个人创造的
Python之包管理工具—pip的安装使用指南
Python有spark库么
Python中关于前后缀操作的详解
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python里怎么查看数据类型