This module defines some constants useful for checking character classes and some useful string functions. See the module re for string functions based on regular expressions.
The constants defined in this module are:
'abcdefghijklmnopqrstuvwxyz'
. This
value is not locale-dependent and will not change.
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
. This
value is not locale-dependent and will not change.
'0123456789'
.
'0123456789abcdefABCDEF'
.
'abcdefghijklmnopqrstuvwxyz'
. Do not change its definition --
the effect on the routines upper() and
swapcase() is undefined. The specific value is
locale-dependent, and will be updated when
locale.setlocale() is called.
'01234567'
.
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
. Do not change its definition --
the effect on the routines lower() and
swapcase() is undefined. The specific value is
locale-dependent, and will be updated when
locale.setlocale() is called.
Many of the functions provided by this module are also defined as methods of string and Unicode objects; see ``String Methods'' (section 2.2.6) for more information on those. The functions defined in this module are:
Convert a string to a floating point number. The string must have the standard syntax for a floating point literal in Python, optionally preceded by a sign ("+" or "-"). Note that this behaves identical to the built-in function float() when passed a string.
Note: When passing in a string, values for NaN and Infinity may be returned, depending on the underlying C library. The specific set of strings accepted which cause these values to be returned depends entirely on the C library and is known to vary.
Convert string s to an integer in the given base. The string must consist of one or more digits, optionally preceded by a sign ("+" or "-"). The base defaults to 10. If it is 0, a default base is chosen depending on the leading characters of the string (after stripping the sign): "0x" or "0X" means 16, "0" means 8, anything else means 10. If base is 16, a leading "0x" or "0X" is always accepted, though not required. This behaves identically to the built-in function int() when passed a string. (Also note: for a more flexible interpretation of numeric literals, use the built-in function eval() .)
Convert string s to a long integer in the given base. The string must consist of one or more digits, optionally preceded by a sign ("+" or "-"). The base argument has the same meaning as for atoi(). A trailing "l" or "L" is not allowed, except if the base is 0. Note that when invoked without base or with base set to 10, this behaves identical to the built-in function long() when passed a string.
s[start:end]
. Return -1
on failure.
Defaults for start and end and interpretation of
negative values is the same as for slices.
s[start:end]
.
Defaults for start and end and interpretation of
negative values are the same as for slices.
Warning: Don't use strings derived from lowercase and uppercase as arguments; in some locales, these don't have the same length. For case conversions, always use lower() and upper().
None
, the words are
separated by arbitrary strings of whitespace characters (space, tab,
newline, return, formfeed). If the second argument sep is
present and not None
, it specifies a string to be used as the
word separator. The returned list will then have one more item
than the number of non-overlapping occurrences of the separator in
the string. The optional third argument maxsplit defaults to
0. If it is nonzero, at most maxsplit number of splits occur,
and the remainder of the string is returned as the final element of
the list (thus, the list will have at most maxsplit+1
elements).