title: Converting python2 byte/string encoding to python3
body: <p>I'm communicating over a serial port, and currently using python2 code which I want to convert to python3. I want to make sure the bytes I send over the wire are the same, but I'm having trouble verifying that that's the case.</p>
  
  <p>In the original code the commands are sent like this:</p>
  
  <pre><code>serial.Serial().write("\xaa\xb4" + chr(2))
  </code></pre>
  
  <p>If I <code>print "\xaa\xb4"</code> in python2 I get this: ��.<br>
  If I <code>print("\xaa\xb4")</code> in python3 I get this: ª´</p>
  
  <p>Encoding and decoding seem opposite too:</p>
  
  <p>Python2: <code>print "\xaa".decode('latin-1')</code> -> ª<br>
  Python3: <code>print("\xaa".encode('latin-1'))</code> -> <code>b'\xaa'</code></p>
  
  <p>To be crude, what do I need to send in <code>serial.write()</code> in python3 to make sure exactly the same sequence of <code>1</code>s and <code>0</code>s are sent down the wire?</p>