我有一个这样的清单:
a = ['4.2332e-9']
我认为这里的数字是一个字符串,我需要它作为一个数字。如果我尝试:
a1 = float(a)
我收到错误:
float() argument must be a string or a number.
如果我尝试:
a1 = Decimal(a)
我也收到错误:
Invalid tuple size in creation of Decimal from list or tuple. The list or tuple should have exactly three elements.
关于如何解决它的任何想法?
答案 0 :(得分:0)
lst = ['4.2332e-9', '-8', '5.7', '6.423', '-5', '-6.77', '10']
print map(float, lst)