How can I convert a character to a integer in Python, and viceversa?
Use chr()
and ord()
:
>>> chr(97)
'a'
>>> ord('a')
97
>>> ord('a')
97
>>> chr(97)
'a'
Use chr()
and ord()
:
>>> chr(97)
'a'
>>> ord('a')
97
>>> ord('a')
97
>>> chr(97)
'a'