Reputation: 5774
My return result from my database looks like :
a = [Decimal('0.4441'), Decimal('0.3821'), Decimal('0.4414'), Decimal('0.3391')]
How can I convert it to :
a = [0.4441, 0.3821, 0.4414, 0.3391]
Upvotes: 0
Views: 5308
Reputation: 1
Try to use the index 0, as in: for i in a: print(i[0])
this will get rid of the "extra information" and will only leave you your number (in decimals).
Upvotes: 0
Reputation: 133574
>>> from decimal import Decimal
>>> a = [Decimal('0.4441'), Decimal('0.3821'), Decimal('0.4414'), Decimal('0.3391')]
>>> a = [float(n) for n in a]
>>> a
[0.4441, 0.3821, 0.4414, 0.3391]
I don't see why you would want to do this, you are just losing precision.
Upvotes: 6