代码点读机 / Python / 数字

数字 Python · 数字

数字分整数 int 和浮点数 float:不带小数点的是整数(如 42),带小数点的是浮点数(如 3.14);科学计数法如 1e3 也是浮点数。

怎么用

42  /  3.14

小例子

print(type(42))
print(type(3.14))

运行结果

<class 'int'>
<class 'float'>

官方文档:https://docs.python.org/zh-cn/3/library/stdtypes.html

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条