title: Converting emojis to Unicode and vice versa in python 3
body: <p>I am trying to convert an emoji into its Unicode in python 3. For example I would have the emoji  and from this would like to get the corresponding unicode 'U+1F600'. Similarly I would like to convert the 'U+1F600' back to . Now I have read the documentation and tried several options but pythons behaviour confuses me here. </p>
  
  <pre><code>&gt;&gt;&gt; x = ''
  &gt;&gt;&gt; y = x.encode('utf-8')
  &gt;&gt;&gt; y
  b'\xf0\x9f\x98\x80'
  </code></pre>
  
  <p>The emoji is converted to a byte object.</p>
  
  <pre><code>&gt;&gt;&gt; z = y.decode('utf-8')
  &gt;&gt;&gt; z
  ''
  </code></pre>
  
  <p>Converted the byte object back to the emoji, so far so good.</p>
  
  <p>Now, taking the unicode for the emoji:</p>
  
  <pre><code>&gt;&gt;&gt; c = '\U0001F600'
  &gt;&gt;&gt; d = c.encode('utf-8')
  &gt;&gt;&gt; d
  &gt;&gt;&gt; b'\xf0\x9f\x98\x80'
  </code></pre>
  
  <p>This prints out the byte encoding again.</p>
  
  <pre><code>&gt;&gt;&gt; d.decode('utf-8')
  &gt;&gt;&gt; ''
  </code></pre>
  
  <p>This prints the emoji out again. I really can't figure out how to convert solely between the Unicode and the emoji.</p>