I am executing a mysql query in python using the MySQLdb package. The code looks something like this:
c=db.cursor()
c.execute("""select * from table""")
output = []
for row in c:
output.append(row[4])
where row[4]
contains a decimal value that I want to store in the output
list.
The problem is every value that I am getting looks like this: Decimal('XX.XX')
where all I want in the output
list is XX.XX. At the end of the script, my output
list looks like this:
[Decimal('10.02'), Decimal('20.24'), ...]
But I need it to just contain the numbers, like this:
[10.02, 20.24, ...]
How do I do that?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…