These are the string methods which both 8-bit strings and Unicode objects support:
) |
For 8-bit strings, this method is locale-dependent.
width) |
sub[, start[, end]]) |
[start:end]
. Optional arguments start and
end are interpreted as in slice notation.
[encoding[, errors]]) |
'strict'
, meaning that encoding errors raise
ValueError. Other possible values are 'ignore'
and
'replace'
.
New in version 2.2.
[encoding[,errors]]) |
'strict'
, meaning that encoding errors raise a
ValueError. Other possible values are 'ignore'
and
'replace'
.
New in version 2.0.
suffix[, start[, end]]) |
True
if the string ends with the specified suffix,
otherwise return False
. With optional start, test beginning at
that position. With optional end, stop comparing at that position.
[tabsize]) |
8
characters is assumed.
sub[, start[, end]]) |
-1
if sub is
not found.
sub[, start[, end]]) |
) |
For 8-bit strings, this method is locale-dependent.
) |
For 8-bit strings, this method is locale-dependent.
) |
For 8-bit strings, this method is locale-dependent.
) |
For 8-bit strings, this method is locale-dependent.
) |
For 8-bit strings, this method is locale-dependent.
) |
For 8-bit strings, this method is locale-dependent.
) |
For 8-bit strings, this method is locale-dependent.
seq) |
width) |
len(s)
.
) |
For 8-bit strings, this method is locale-dependent.
[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.2:
Support for the chars argument.
old, new[, count]) |
sub [,start [,end]]) |
-1
on failure.
sub[, start[, end]]) |
width) |
len(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.2:
Support for the chars argument.
[sep [,maxsplit]]) |
maxsplit+1
elements). If maxsplit is not specified or is zero, then there
is no limit on the number of splits (all possible splits are made).
Consecutive delimiters are not grouped together and are
deemed to delimit empty strings (for example, "'1,,2'.split(',')"returns "['1', '', '2']"). The sep argument may consist of
multiple characters (for example, "'1, 2, 3'.split(', ')" returns
"['1', '2', '3']"). Splitting an empty string with a specified
separator returns an empty list.
If sep is not specified or is None
, a different splitting
algorithm is applied. Words are separated by arbitrary length strings of
whitespace characters (spaces, tabs, newlines, returns, and formfeeds).
Consecutive whitespace delimiters are treated as a single delimiter
("'1 2 3'.split()" returns "['1', '2', '3']"). Splitting an
empty string returns "['']".
[keepends]) |
prefix[, start[, end]]) |
True
if string starts with the prefix, otherwise
return False
. With optional start, test string beginning at
that position. With optional end, stop comparing string at that
position.
[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.2:
Support for the chars argument.
) |
For 8-bit strings, this method is locale-dependent.
) |
For 8-bit strings, this method is locale-dependent.
table[, deletechars]) |
For Unicode objects, the translate() method does not
accept the optional deletechars argument. Instead, it
returns a copy of the s where all characters have been mapped
through the given translation table which must be a mapping of
Unicode ordinals to Unicode ordinals, Unicode strings or None
.
Unmapped characters are left untouched. Characters mapped to None
are deleted. Note, a more flexible approach is to create a custom
character mapping codec using the codecs module (see
encodings.cp1251 for an example).
) |
For 8-bit strings, this method is locale-dependent.
width) |
len(s)
.
New in version 2.2.2.
See About this document... for information on suggesting changes.