Displaying Special Characters Using Unicode
Question:
I want to know how to type a special character "Cherry" like the fruit. I got the Unicode string and attempted to display it, but for some reason it sees the 2
within u1F352
as part of the string and not the Unicode sequence, so it displays something completely different: ἵ2
.
import sys
print('u1F352')
Answers:
Using the unicode escape:
>>> print("U0001F352")
Using the unicode name:
>>> print("N{cherries}")
Using the codepoint:
>>> print(chr(0x1f352))
I want to know how to type a special character "Cherry" like the fruit. I got the Unicode string and attempted to display it, but for some reason it sees the 2
within u1F352
as part of the string and not the Unicode sequence, so it displays something completely different: ἵ2
.
import sys
print('u1F352')
Using the unicode escape:
>>> print("U0001F352")
Using the unicode name:
>>> print("N{cherries}")
Using the codepoint:
>>> print(chr(0x1f352))