Below is my String.
str = '0.00007515'
tried below
mainValue = float(str) gives me 7.515e-05 output.
mainValue =Decimal(str) gives me 0.0 output
I wanted to output in 0.00007515 float or other datatype. How can i solve this.
Just specify that you need 8 digits after the decimal point when printing the value!
mainValue = float(str)
print("{:.8f}".format(mainValue))
以您需要的精度使用简单的格式功能。
print("{0:.8f}".format(float(str)))
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.