ord python3
# The ord() function returns an integer representing the Unicode character.
res = ord('A')
print(res)
# output 65
5
1
# ord('a') means 'get unicode of a'
ord('a') = 97
# chr(97) is the reverse, and means 'get ascii of 97'
chr(97) = 'a'
# to get the int val of a single digit represented as a char, do the following:
# ord(single_digit_char) - ord('0') = single_digit_int
ord('5') - ord('0') = 5
ord('3') - ord('0') = 3
Thank you!
1
0
Are there any code examples left?
New code examples in category Python