Variables and functions for working with character strings.
digits
The decimal digits: "0123456789".
hexdigits
The hexadecimal digits: "0123456789abcdefABCDEF".
letters
All the letters: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".
lowercase
All the lowercase letters:
"abcdefghijklmnopqrstuvwxyz".
maketrans(s, t)
Builds a translation table to be used as the first
argument to the .translate() string
method. The arguments and s are two strings of the
same length; the result is a translation table that
will convert each character of t to the corresponding
character of s.
t
>>> import string
>>> bingo=string.maketrans("lLrR", "rRlL")
>>> "Cornwall Llanfair".translate(bingo)
'Colnwarr Rranfail'
>>> "Cornwall Llanfair".translate(bingo, 'ai')
'Colnwrr Rrnfl'
octdigits
The octal digits: "01234567".
printable
A string containing all the printable characters.
punctuation
All printable characters that are not letters or digits, to wit:
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
uppercase
All the uppercase characters:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".
whitespace
A string containing all the characters considered to be white space, namely:
"\t\n\x0b\x0c\r "
In order, they are: tab, newline, vertical tab, form feed, carriage return, and space.