how to change 39.54484700000000 to 39.54 and using python

You can use the quantize method if you're using a Decimal:

In [24]: q = Decimal('0.00')

In [25]: d = Decimal("115.79341800000000")

In [26]: d.quantize(q)
Out[26]: Decimal("115.79")

How about round

>>> import decimal
>>> d=decimal.Decimal("39.54484700000000")
>>> round(d,2)
39.54

>>> round(39.54484700000000, 2)
39.54

Note, however, that the result isn't actually 39.54, but 39.53999999999999914734871708787977695465087890625.


If you want to change the actual value, use round as Eli suggested. However for many values and certain versions of Python this will not result be represented as the string "39.54". If you want to just round it to produce a string to display to the user, you can do

>>> print "%.2f" % (39.54484700000000)
39.54

or in newer versions of Python

>>> print("{:.2f}".format(39.54484700000000))
39.54

or with the fstrings

>>> print(f'{39.54484700000000:.2f}')
39.54

Relevant Documentation: String Formatting Operations, Built-in Functions: round