title: Escape special HTML characters in Python
body: <p>I have a string where special characters like <code>'</code> or <code>"</code> or <code>&amp;</code> (...) can appear. In the string:</p>
  
  <pre><code>string = """ Hello "XYZ" this 'is' a test &amp; so on """
  </code></pre>
  
  <p>how can I automatically escape every special character, so that I get this:</p>
  
  <pre><code>string = " Hello &amp;quot;XYZ&amp;quot; this &amp;#39;is&amp;#39; a test &amp;amp; so on "
  </code></pre>