我有一个这样的名单:小数与指数
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.
的任何想法我怎么能解决它?
您有一个字符串列表,而不是一个字符串。 'float'需要一个字符串,所以'float(a [0])''。 – DyZ
[TypeError:float()参数的可能重复必须是字符串或数字,而不是'list'python](http://stackoverflow.com/questions/37629828/typeerror-float-argument-must-bea-a- string-or-a-number-not-list-python) – DyZ