mantissa, exp = s.split('e')
return '%se%+0*d' % (mantissa, exp_digits + 1, int(exp))
print(eformat(8.70927939438012e-05, 14, 3))
print(eformat(100008.70927939437, 14, 3))
print(eformat(1.1e+123, 4, 4))
print(eformat(1.1e-123, 4, 4))
Python - number of digits in exponent