The following list of functions are also defined as methods of string and Unicode objects; see ``String Methods'' (section 3.6.1) for more information on those. You should consider these functions as deprecated, although they will not be removed until Python 3.0. The functions defined in this module are:
s) |
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.
s[, base]) |
s[, base]) |
word) |
s[, tabsize]) |
s, sub[, start[,end]]) |
s[start:end]
. Return -1
on failure.
Defaults for start and end and interpretation of
negative values is the same as for slices.
s, sub[, start[, end]]) |
s, sub[, start[, end]]) |
s, sub[, start[, end]]) |
s, sub[, start[, end]]) |
s[start:end]
.
Defaults for start and end and interpretation of
negative values are the same as for slices.
s) |
s[, sep[, maxsplit]]) |
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).
The behavior of split on an empty string depends on the value of sep.
If sep is not specified, or specified as None
, the result will
be an empty list. If sep is specified as any string, the result will
be a list containing one element which is an empty string.
s[, sep[, maxsplit]]) |
maxsplit+1
elements).
New in version 2.4.
s[, sep[, maxsplit]]) |
words[, sep]) |
words[, sep]) |
s[, chars]) |
None
, whitespace characters are
removed. If given and not None
, chars must be a string;
the characters in the string will be stripped from the beginning of
the string this method is called on.
Changed in version 2.2.3:
The chars parameter was added. The chars
parameter cannot be passed in earlier 2.2 versions.
s[, chars]) |
None
, whitespace characters are
removed. If given and not None
, chars must be a string;
the characters in the string will be stripped from the end of the
string this method is called on.
Changed in version 2.2.3:
The chars parameter was added. The chars
parameter cannot be passed in earlier 2.2 versions.
s[, chars]) |
None
, whitespace
characters are removed. If given and not None
, chars
must be a string; the characters in the string will be stripped from
the both ends of the string this method is called on.
Changed in version 2.2.3:
The chars parameter was added. The chars
parameter cannot be passed in earlier 2.2 versions.
s) |
s, table[, deletechars]) |
s) |
s, width) |
s, width) |
s, width) |
s, width) |
str, old, new[, maxreplace]) |