首页 > 编程语言 > 详细

python中的type

时间:2017-09-10 20:16:38      阅读:241      评论:0      收藏:0      [点我收藏+]

我们常用type()来查看类型,使用方法如下:

 1 a = "zzzq"
 2 b = 1
 3 c = (1, "zzq123")
 4 d = [2, "dlrb"]
 5 e = {}
 6 a1 = type(a)
 7 b1 = type(b)
 8 c1 = type(c)
 9 d1 = type(d)
10 e1 = type(e)
11 print a1, b1, c1, d1, e1

我们可以看到我们提供了五种类型的变量,使用type()来获取类型并输出它

输出结果:

<type str> <type int> <type tuple> <type list> <type dict>

我们看到了:a的类型是字符串,b的类型是整数,c的类型是元组,d的类型是列表,e的类型是字典

python中的type

原文:http://www.cnblogs.com/zhangzengqiang/p/7501972.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!