views:

4322

answers:

4

I want to get, given a character, its ascii value.

For example, for the character 'a', I want to get 97, and viceversa.

Thanks,
Manuel

+1  A: 

ord and chr

sysrqb
+3  A: 
>>> ord('a')
97
>>> chr(97)
'a'
dwc
+19  A: 

Use chr() and ord():

>>> chr(97)
'a'
>>> ord('a')
97
Adam Rosenfield
+1 - Simple, to the point and linking to the manual.
Luiz Damim
+3  A: 

The question has been answered but I think this reference is a good thing to keep note of. http://docs.python.org/library/functions.html

Trey Stout