Write the ord(c) function.
ord(c)
returns the Unicode int
value of the parameter c
.
Conversely, when converting the int
value to character
, use the chr(i) function.
chr(i) returns the ASCII code i
and the corresponding string (len=1
).
stringToInt = ord('a')
intToString = chr(stringToInt)
print stringToInt
print intToString
Results)
97
a
In addition, unichar(i) returns a string (len=1
) with a Unicode value of i
.
print unichr(97)
print unichr(1234)
Results)
a
Ӓ
© 2024 OneMinuteCode. All rights reserved.