How can I convert a character to a integer in Python, and viceversa?
PythonIntegerCharType ConversionPython Problem Overview
I want to get, given a character, its ASCII
value.
For example, for the character a
, I want to get 97
, and vice versa.
Python Solutions
Solution 1 - Python
Solution 2 - Python
>>> ord('a')
97
>>> chr(97)
'a'
Solution 3 - Python
ord and chr
Solution 4 - Python
For long string you could use this.
''.join(map(str, map(ord, 'pantente')))