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://codercto.com/courses/l/10.html

查看所有标签

The Definitive Guide to MongoDB

The Definitive Guide to MongoDB

Peter Membrey、Wouter Thielen / Apress / 2010-08-26 / USD 44.99

MongoDB, a cross-platform NoSQL database, is the fastest-growing new database in the world. MongoDB provides a rich document orientated structure with dynamic queries that you’ll recognize from RDMBS ......一起来看看 《The Definitive Guide to MongoDB》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具