首页 > 编程语言 > 详细

python---类型检查

时间:2020-03-18 22:13:02      阅读:61      评论:0      收藏:0      [点我收藏+]
# 通过类型检查,可以检查指定值(变量)的类型

# a=123  数值
# b=‘123‘  字符串

# type()用来检查值得类型
# 该函数会将检查的结果作为返回值返回,可以通过变量来接受函数的返回值
# c = type(‘123‘)
# print(c)   结果为<class ‘str‘>


print(type(2))       <class int>
print(type(2.6))     <class float>
print(type(True))    <class bool>
print(type(None))    <class NoneType>

 

python---类型检查

原文:https://www.cnblogs.com/oyaisusu/p/12520237.html

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