755

4 分钟

#Python 的内置函数 float

说明:类型转换为 float

#函数说明

class float(x=0.0): ''' 类型转换为 float :param x: 一个变量 :return: 转换为 float 后的值 '''

说明

将变量转换为 float 类型。

参数

  • x - 要转换的变量

返回值

转换为 float 后的值。

#示例

print(float(100)) # int 转 float print(float('100')) # str 转 float print(float('2e10')) # 科学计数法 print(float(' 3.14\n')) print(float("inf")) # 特殊值: inf(正无穷) print(float("-inf")) # 特殊值: -inf(负无穷) print(float("nan")) # 特殊值: nan(非数字)

>>> Establishing WebAssembly Runtime.

>>> Standby.

Powered by Shift.

#推荐阅读

创建于 2025/6/9

更新于 2025/6/17