“Python func float”的版本间差异
本页内容
(创建页面,内容为“{{DISPLAYTITLE:float(x)}}2 = Python float() 函数 = Python 内置函数 == 描述 == '''float()''' 函数用于将整数和字符串转换成浮点数。 == 语法 == float()方法语法: <sample title="" desc="" lang="python" hererun="1"> class float([x]) </sample> == 参数 == * x -- 整数或字符串 == 返回值 == 返回浮点数。 以下实例展示了 float() 的使用方法:…”) |
无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第1行: | 第1行: | ||
{{DISPLAYTITLE:float( | {{DISPLAYTITLE:float()}}[[Category:python3 built in functions|36]] | ||
= Python float() 函数 = | = Python float() 函数 = | ||
第25行: | 第25行: | ||
以下实例展示了 float() 的使用方法: | 以下实例展示了 float() 的使用方法: | ||
<sample title="" desc="" lang="python" hererun="1"> | <sample title="" desc="" lang="python" hererun="1"> | ||
>>>float(1) | >>>float(1) | ||
1.0 | 1.0 | ||
第34行: | 第34行: | ||
>>> float('123') # 字符串 | >>> float('123') # 字符串 | ||
123.0 | 123.0 | ||
</sample> | |||
[[python built in functions|Python 内置函数]] | [[python built in functions|Python 内置函数]] |
2022年8月17日 (三) 21:49的最新版本
Python float() 函数
描述
float() 函数用于将整数和字符串转换成浮点数。
语法
float()方法语法:
示例
class float([x])
参数
- x -- 整数或字符串
返回值
返回浮点数。
以下实例展示了 float() 的使用方法:
示例
>>>float(1)
1.0
>>> float(112)
112.0
>>> float(-123.6)
-123.6
>>> float('123') # 字符串
123.0