标签:
1、整数字符串转浮点数
>>> float(3)
3.0
>>> float(‘4.2‘)
4.2
>>> str(4)
‘4‘
>>> str(4.3345)
‘4.3345‘
>>> int(‘5‘)
5
>>> int(5.89)
5
>>> round(5.89)
6
>>> round(5.5)
6
>>> round(4.5)
4
>>> int(‘5.3‘)
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
int(‘5.3‘)
ValueError: invalid literal for int() with base 10: ‘5.3‘
>>>
标签:
原文地址:http://www.cnblogs.com/fange666/p/4676582.html