Integer to string without exponent
I have a number a=11**20
and I need to output it to a string.
But str(a)
doesn't fit the way it will:
'6.727499949325601e+20'
, and I need it to be an integer without an exponent:
'672749994932560009201'
1
1 answers
Most likely you have a fractional number:
In [18]: str(11.0**20)
Out[18]: '6.727499949325601e+20'
To specify the format you need, use string formatting:
In [19]: res = '{:.0f}'.format(11.0**20)
In [20]: res
Out[20]: '672749994932560068608'
5
Author: MaxU, 2018-04-07 19:48:13