Loading

python---类型检查

# 通过类型检查,可以检查指定值(变量)的类型

# 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'>

 

posted @ 2020-03-18 21:09  -Heart-  阅读(1949)  评论(0)    收藏  举报