Character Sequence Generation

mensanator at aol.com mensanator at aol.com
Fri Sep 23 00:07:22 EDT 2005


Jeff Schwab wrote:
> What's the best way to generate a sequence of characters in Python?  I'm
> looking for something like this Perl code: 'a' .. 'z' .

>>> import string

>>> print string.ascii_lowercase
abcdefghijklmnopqrstuvwxyz


Others:

ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xcd\xce...
lowercase =
'abcdefghijklmnopqrstuvwxyz\x83\x9a\x9c\x9e\xaa\xb5\xba\xd...
octdigits = '01234567'
printable =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
uppercase =
'ABCDEFGHIJKLMNOPQRSTUVWXYZ\x8a\x8c\x8e\x9f\xc0\xc1\xc2\xc...
whitespace = '\t\n\x0b\x0c\r '




More information about the Python-list mailing list