Python float() 函数

Python 3 教程 · 2019-02-05 08:28:25

描述

float() 函数用于将整数和字符串转换成浮点数。

语法

float()方法语法:

class float([x])

参数

  • x -- 整数或字符串

返回值

返回浮点数。

实例

以下实例展示了 float() 的使用方法:

>>>float(1) 1.0 >>> float(112) 112.0 >>> float(-123.6) -123.6 >>> float('123') # 字符串 123.0

点击查看所有 Python 3 教程 文章: https://www.codercto.com/courses/l/10.html

查看所有标签

The Art and Science of CSS

The Art and Science of CSS

Jonathan Snooks、Steve Smith、Jina Bolton、Cameron Adams、David Johnson / SitePoint / March 9, 2007 / $39.95

Want to take your CSS designs to the next level? will show you how to create dozens of CSS-based Website components. You'll discover how to: # Format calendars, menus and table of contents usin......一起来看看 《The Art and Science of CSS》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具