string

The string module contains a number of useful constants and functions for manipulating strings. Most of the functionality of this module is also available in the form of string methods. The following constants are defined:

ConstantDescription
ascii_lettersA string containing all lowercase and uppercase ASCII letters.
ascii_lowercaseThe string 'abcdefghijklmnopqrstuvwxyz'.
ascii_uppercaseThe string 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
digitsThe string '0123456789'.
hexdigitsThe string '0123456789abcdefABCDEF'.
lettersConcatenation of lowercase and uppercase.
lowercaseString containing all lowercase letters specific to the current locale setting.
octdigitsThe string '01234567'.
punctuationString of ASCII punctuation characters.
printableString of printable ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.