Substitute special characters with html entities in Python
<p>I have a string where special characters like ' or " or &amp; (...) can appear. How can I convert in the string</p>

<pre><code>string = " Hello "XYZ" this 'is' a test &amp; so on "
</code></pre>

<p>automatically every special characters with theire html entities, 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>

<p>Thanks!</p>
