title: How do I parse a string to a float or int?
body: <ul>
  <li>How can I convert a <code>str</code> to <code>float</code>?
  <pre><code>&quot;545.2222&quot;  →  545.2222
  </code></pre>
  </li>
  <li>How can I convert a <code>str</code> to <code>int</code>?
  <pre><code>&quot;31&quot;        →  31
  </code></pre>
  </li>
  </ul>
  <hr />
  <p><sub>For the reverse, see <a href="https://stackoverflow.com/questions/961632">Convert integer to string in Python</a> and <a href="https://stackoverflow.com/questions/1317558">Converting a float to a string without rounding it</a>.</sub></p>
  <p><sub>Please instead use <a href="https://stackoverflow.com/questions/20449427">How can I read inputs as numbers?</a> to close duplicate questions where OP received a string <em>from user input</em> and immediately wants to convert it, or was hoping for <code>input</code> (in 3.x) to convert the type automatically.</sub></p>