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.
>>> x = '😀'
>>> y = x.encode('utf-8')
>>> y
b'\xf0\x9f\x98\x80'
The emoji is converted to a byte object.
>>> z = y.decode('utf-8')
>>> z
'😀'
Converted the byte object back to the emoji, so far so good.
Now, taking the unicode for the emoji:
>>> c = '\U0001F600'
>>> d = c.encode('utf-8')
>>> d
>>> b'\xf0\x9f\x98\x80'
This prints out the byte encoding again.
>>> d.decode('utf-8')
>>> '😀'
This prints the emoji out again. I really can't figure out how to convert solely between the Unicode and the emoji.