These are the string methods which both 8-bit strings and Unicode objects support:
) |
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]]) |
) |
) |
) |
) |
) |
) |
) |
seq) |
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 beginning of
the string this method is called on.
Changed in version 2.2.2:
Support for the chars argument.
old, new[, maxsplit]) |
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]]) |
None
, any
whitespace string is a separator.
[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.
) |
) |
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).
) |
width) |
len(s)
.
New in version 2.2.2.
See About this document... for information on suggesting changes.