Write floating point numbers without any decimal places
<p>I'm trying to have Python replicate some FORTRAN output of real values. My FORTRAN prints the real value as "31380.". I'm trying to replicate the same in Python--note that although I have no decimal places, I actually want the decimal point (period) to be printed. My current code is</p>

<pre><code>htgm=31380.
print '{:6.0f}'.format(htgm)
</code></pre>

<p>which yields "31380". What am I doing wrong?</p>

<p>It is not possible to do it Python keeping the type of <code>htgm</code> as <code>float</code>. However if you are OK with making it as <code>str</code>, you may do:</p>

<pre><code>htgm=31380.
'{0:.0f}.'.format(htgm)
# returns: '31380.'

# OR, even simply
'{}.'.format(int(htgm))
</code></pre>

python string format