Let's say i have following variables:
something = 123456789
decimal = 5
I want to set the decimal place of something
based on the value of decimal
so that for the above example i get:
something = 1234.56789
Now let's say decimal = 15
then i need to get:
something = 0.000000123456789
How to do this in the most pythonic way?
Simply by dividing with 10 to the power of decimal.
something = 123456789
decimal = 15
print(something / 10 ** decimal)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.