数据类型就是变量值的类型,也就是可以为变量赋哪些值
1.数值: 整数:包括布尔值True和False(进行逻辑判断,True相当于1,False相当于0,是整数类型);
浮点数;
复数;
2.字符串;str
3.空值;None:空值,表示不存在;
检查值的类型用type()函数
print(type(2))
print(type(3.5))
print(type(True))
print(type('hello'))
print(type(None))
<class 'int'>
<class 'float'>
<class 'bool'>
<class 'str'>
<class 'NoneType'>
本文深入讲解了Python中的数据类型,包括数值(整数、浮点数、复数)、字符串、空值等,以及如何使用type()函数来检查值的类型。

被折叠的 条评论
为什么被折叠?



