title: How to replace {{var}} in an HTML document to a variable using Python 3
body: <p>How can I put variables from dict into an HTML document?</p>
  <p>Like in replace {{variable}} with 1 in the HTML document with Python.</p>
  <p>Python code:</p>
  <pre class="lang-py prettyprint-override"><code>def convert_html_to_python(variables={}, code=&quot;&quot;):
      ## Stuff with code variable
  some_code = &quot;&quot;&quot;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;body&gt;
      &lt;h1&gt;My First Heading&lt;/h1&gt;
      &lt;p&gt;My first paragraph.&lt;/p&gt;
      {{var}}
  &lt;/body&gt;
  &lt;/html&gt;
  &quot;&quot;&quot;
  convert_html_to_python({&quot;var&quot;:&quot;1&quot;}, some_code)
  
  </code></pre>
  <p>Then the Python script converts HTML document to:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;body&gt;
      &lt;h1&gt;My First Heading&lt;/h1&gt;
      &lt;p&gt;My first paragraph.&lt;/p&gt;
      1
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>I want it to be like <a href="https://en.wikipedia.org/wiki/Django_%28web_framework%29" rel="nofollow noreferrer">Django</a> templates. I do not want to use Django or Flask.</p>