如果无参数将返回0

如果无参数将返回0

float([x]): 将一个字符串或数转换为浮点数。如果无参数将返回0.0

>>> float(12)
12.0
>>> float(-122)
-122.0
>>> float('ada')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: ada
>>> float()
0.0
>>>
04-11 04:01