Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 1.34 KB

File metadata and controls

44 lines (34 loc) · 1.34 KB
title Python float() 内置函数 - Python 速查表
description 从数字或字符串 x 构建浮点数。
Python float() 内置函数 来自 Python 3 文档 从数字或字符串 x 构建一个浮点数。

简介

Python 中的 float() 函数是一个内置函数,它允许您将数字或包含数字的字符串转换为浮点数。当您需要执行需要小数精度的算术运算时,这特别有用。

float() 函数从数字或字符串返回一个浮点数。

示例

float('10')
float(10)
10.0
10.0

相关链接

  • int()
  • complex()
  • Python 数据类型
  • str()
  • round()
  • 字符串格式化