| title | Python float() 内置函数 - Python 速查表 |
|---|---|
| description | 从数字或字符串 x 构建浮点数。 |
Python 中的 float() 函数是一个内置函数,它允许您将数字或包含数字的字符串转换为浮点数。当您需要执行需要小数精度的算术运算时,这特别有用。
float() 函数从数字或字符串返回一个浮点数。
float('10')
float(10)10.0
10.0
- int()
- complex()
- Python 数据类型
- str()
- round()
- 字符串格式化