exponential - How do I change the raised power of an exponent in Python? -
i trying fetch value webpage in scientific notation 3.67e+17
, convert form 0.367e+18
. or if scientific notation 0.367e+18
, fetch value. have been able implement part open webpage , find scientific number is, however, haven't been able convert number form want.
i got far though:
lsf = "3.18e+20" int(lsf[lsf.find("e")+2:]) - 18
i have been able figure out how many decimal places need shift, either left or right, however, how shift them?
lsf = "3.18e+20" epos = lsf.find("e") if (epos): mantissa = float(lsf[:epos]) exponent = int(lsf[epos+1:]) else: mantissa = float(lsf) exponent = 0 shift = 18 - exponent result = mantissa / 10**shift
result
new mantissa exponent 18
Comments
Post a Comment