python变量的数据类型

Posted enjie

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python变量的数据类型相关的知识,希望对你有一定的参考价值。

变量在赋值时会自动判断数据的类型

python最常用的有四种数据类型

字符串 - str(string)

整数 - int(integer)

浮点数 - float

布尔型 - bool(boolean)

 

type函数用于得到变量的数据类型

语法: 变量 = type(变量名)

输出: str  |  int  |  float  |  bool

print(type(变量名)) #函数套用

以上是关于python变量的数据类型的主要内容,如果未能解决你的问题,请参考以下文章