title: How to base64 encode/decode a variable with string type in Python 3?
body: <p>It gives me an error that the line encoded needs to be bytes not str/dict</p>
  
  <p>I know of adding a "b" before the text will solve that and print the encoded thing.</p>
  
  <pre><code>import base64
  s = base64.b64encode(b'12345')
  print(s)
  &gt;&gt;b'MTIzNDU='
  </code></pre>
  
  <p>But how do I encode a variable?
  such as</p>
  
  <pre><code>import base64
  s = "12345"
  s2 = base64.b64encode(s)
  print(s2)
  </code></pre>
  
  <p>It gives me an error with the b added and without. I don't understand</p>
  
  <p>I'm also trying to encode/decode a dictionary with base64.</p>