Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 401 Bytes

File metadata and controls

22 lines (17 loc) · 401 Bytes
@author jackzhenguo
@desc 
@date 2019/2/15

9 转为浮点类型 

将一个整数或数值型字符串转换为浮点数

In [1]: float(3)
Out[1]: 3.0

如果不能转化为浮点数,则会报ValueError:

In [2]: float('a')
# ValueError: could not convert string to float: 'a'
[上一个例子](8.md) [下一个例子](10.md)