0

I've been looking for something that can transform each character into its respective unicode code like this:

U+0021 = !
U+0022 = "
U+002D = -
U+0039 = 9
U+0041 = A
U+0042 = B
U+0061 = a
U+0062 = b
U+007E = ~
U+00C0 = À
U+00E3 = ã
U+00E7 = ç
U+00E9 = é
U+00FF = ÿ
U+03A3 = Σ
U+03B1 = α
U+2014 = —
U+201C = “ 

  • Do you want to display the character or find the code ? you can just type "\U00000021" this will output the expected character. – Malo Mar 07 '21 at 12:28

1 Answers1

0

No need to import a module. You can use ord():

my_string ="A"
print('U+%04x' %ord(my_string))

#output: U+0041
pakpe
  • 5,391
  • 2
  • 8
  • 23