Is there a Python Library that contains a list of all the ascii characters?

rectangletangle picture rectangletangle · May 5, 2011 · Viewed 125.5k times · Source

Something like below:

import ascii

print ascii.charlist()

Which would return something like [A, B, C, D...]

Answer

Acorn picture Acorn · May 5, 2011

The string constants may be what you want. (docs)

>>> import string
>>> string.ascii_uppercase
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

If you want all printable characters:

>>> string.printable
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;?@[\\]^_`{|}~ \t\n\r\x0b\x0c'