The string Module
The string module supplies functions that duplicate each method of string objects, as covered in Methods of String Objects. Each function takes the (plain or Unicode) string object as its first argument. Module string also supplies several useful plain-string attributes:
ascii_lettersThe string
ascii_lowercase+ascii_uppercaseascii_lowercaseThe string
'abcdefghijklmnopqrstuvwxyz'ascii_uppercaseThe string
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'digitsThe string
'0123456789'hexdigitsThe string
'0123456789abcdefABCDEF'lettersThe string
lowercase+uppercaselowercaseA string containing all characters that are deemed lowercase letters: at least
'abcdefghijklmnopqrstuvwxyz', but more letters (e.g., accented ones) may be present, depending on the active localeoctdigitsThe string
'01234567'punctuationThe string
'!"#$%&\'( )*+,-./:;<=>?@[\\]^_'{|}~'(i.e., all ASCII characters that are deemed punctuation characters in the'C'locale; does not depend on which locale is active)printableThe string of those characters that are deemed printable (i.e., digits, letters, punctuation, and whitespace)
uppercaseA string containing all characters that are deemed uppercase letters: at least
'ABCDEFGHIJKLMNOPQRSTUVWXYZ', but more letters (e.g., accented ones) may be present, depending on the active localewhitespaceA string containing all characters that are deemed whitespace: at least space, tab, linefeed, and carriage return, but more characters (e.g., certain control characters) may be present, depending ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access