This module defines some constants useful for checking characterclasses and some useful string functions. See the modulere for string functions based on regularexpressions.
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 routinesupper() andswapcase() is undefined. The specific value is locale-dependent, and will be updated whenlocale.setlocale() is called.'01234567'.'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. Do not change its definition -- the effect on the routineslower() andswapcase() is undefined. The specific value is locale-dependent, and will be updated whenlocale.setlocale() is called.Many of the functions provided by this module are also defined asmethods of string and Unicode objects; see ``String Methods'' (section2.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 functionfloat() 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 strings to an integer in the givenbase. The string must consist of one or more digits, optionally preceded by a sign ("+" or "-"). Thebase 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. Ifbase is 16, a leading "0x" or "0X" is always accepted, though not required. This behaves identically to the built-in functionint() when passed a string. (Also note: for a more flexible interpretation of numeric literals, use the built-in functioneval() .)
Convert strings to a long integer in the givenbase. The string must consist of one or more digits, optionally preceded by a sign ("+" or "-"). Thebase argument has the same meaning as foratoi(). A trailing "l" or "L" is not allowed, except if the base is 0. Note that when invoked withoutbase or withbase set to 10, this behaves identical to the built-in functionlong() when passed a string.
s[start:end]. Return-1 on failure. Defaults forstart andend and interpretation of negative values is the same as for slices.s[start:end]. Defaults forstart andend and interpretation of negative values are the same as for slices.Warning:Don't use strings derived fromlowercase anduppercase as arguments; in some locales, these don't have the same length. For case conversions, always uselower() andupper().
None, the words are separated by arbitrary strings of whitespace characters (space, tab, newline, return, formfeed). If the second argumentsep is present and notNone, 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 argumentmaxsplit defaults to 0. If it is nonzero, at mostmaxsplit 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 mostmaxsplit+1 elements).None, whitespace characters areremoved. If given and notNone,chars must be a string;the characters in the string will be stripped from the beginning ofthe string this method is called on.Changed in version 2.2.3:Thechars parameter was added. Thechars parameter cannot be passed in earlier 2.2 versions.None, whitespace characters areremoved. If given and notNone,chars must be a string;the characters in the string will be stripped from the end of thestring this method is called on.Changed in version 2.2.3:Thechars parameter was added. Thechars parameter cannot be passed in earlier 2.2 versions.None, whitespacecharacters are removed. If given and notNone,charsmust be a string; the characters in the string will be stripped fromthe both ends of the string this method is called on.Changed in version 2.2.3:Thechars parameter was added. Thechars parameter cannot be passed in earlier 2.2 versions.| Python Library Reference |