How do you use multiple arguments in {} when using the .format() method in Python
<p>I want a table in python to print like this: </p>

<p><img src="https://i.imgur.com/ymGkIdQ.png" alt=""></p>

<p>Clearly, I want to use the .format() method, but I have long floats that look like this: <code>1464.1000000000001</code> I need the floats to be rounded, so that they look like this: <code>1464.10</code> (always two decimal places, even if both are zeros, so I can't use the round() function).</p>

<p>I can round the floats using <code>"{0:.2f}".format("1464.1000000000001")</code>, but then they do not print into nice tables. </p>

<p>I can put them into nice tables by doing <code>"{0:&gt;15}.format("1464.1000000000001")</code>, but then they are not rounded.</p>

<p>Is there a way to do both? Something like <code>"{0:&gt;15,.2f}.format("1464.1000000000001")</code>?</p>

<pre><code>"{0:15.2f}".format(1464.1000000000001)
</code></pre>

<p>I always find this site useful for this stuff:</p>

<p><a href="https://pyformat.info/" rel="nofollow">https://pyformat.info/</a></p>

python python-3.x rounding string-formatting string.format