- 类型检查
type()用来检查值的类型 (整型、浮点型、布尔值、字符串、空值)
该函数会将检查的结果作为返回值返回,可以通过变量来接收函数的返回值print(type(1)) # <class 'int'> print(type(1.5)) # <class 'float'> print(type(True)) # <class 'bool'> print(type('hello')) # <class 'str'> print(type(None)) # <class 'NoneType'> a=type(123) print('123数字类型检查结果返回值:',a) # 123数字类型检查结果返回值: <class 'int'>
- 类型转换
python类型检查和类型转换
猜你喜欢
转载自www.cnblogs.com/FlyingLiao/p/11142225.html
今日推荐
周排行