02_类型检查

2018-11-05  本文已影响0人  秋的懵懂

时间:2018-11-01 作者:魏文应


一、类型检查

类型检查,通过 type() 内建函数来实现变量类型检查:

a = 123
print(a)
print(type(a))
print(type(1))
print(type(1.5))
print(type(True))
print(type('hello'))
print(type(None))

打印结果如下:

123
<class 'int'>
<class 'int'>
<class 'float'>
<class 'bool'>
<class 'str'>
<class 'NoneType'>
上一篇 下一篇

猜你喜欢

热点阅读