.elems() method to iterate over their characters. Examples:
+ operator instead. Comparison operators perform a lexicographical comparison; use == to test for equality.
Members
- capitalize
- count
- elems
- endswith
- find
- format
- index
- isalnum
- isalpha
- isdigit
- islower
- isspace
- istitle
- isupper
- join
- lower
- lstrip
- partition
- removeprefix
- removesuffix
- replace
- rfind
- rindex
- rpartition
- rsplit
- rstrip
- split
- splitlines
- startswith
- strip
- title
- upper
capitalize
count
sub in string, optionally restricting to [start:end], start being inclusive and end being exclusive.
Parameters
ParameterDescriptionsubstring;
required
The substring to count.
startint; or None;
default is 0
Restrict to search from this position.
endint; or None;
default is None
optional position before which to restrict to search.
elems
[s[i] for i in range(len(s))], except that the returned value might not be a list.
endswith
sub, otherwise False, optionally restricting to [start:end], start being inclusive and end being exclusive.
Parameters
ParameterDescriptionsubstring; or tuple of string s;
required
The suffix (or tuple of alternative suffixes) to match.
startint; or None;
default is 0
Test beginning at this position.
endint; or None;
default is None
optional position at which to stop comparing.
find
sub is found, or -1 if no such index exists, optionally restricting to [start:end], start being inclusive and end being exclusive.
Parameters
ParameterDescriptionsubstring;
required
The substring to find.
startint; or None;
default is 0
Restrict to search from this position.
endint; or None;
default is None
optional position before which to restrict to search.
format
{}. Anything that is not contained in braces is considered literal text, which is copied unchanged to the output.If you need to include a brace character in the literal text, it can be escaped by doubling: {{ and }} A replacement field can be either a name, a number, or empty. Values are converted to strings using the str function.
Parameters
ParameterDescriptionargs
default is ()
List of arguments.
kwargs
default is {}
Dictionary of arguments.
index
sub is found, or raises an error if no such index exists, optionally restricting to [start:end] start being inclusive and end being exclusive.
Parameters
ParameterDescriptionsubstring;
required
The substring to find.
startint; or None;
default is 0
Restrict to search from this position.
endint; or None;
default is None
optional position before which to restrict to search.
isalnum
isalpha
isdigit
islower
isspace
istitle
isupper
join
Parameters
ParameterDescriptionelements
iterable of string s;
required
The objects to join.
lower
lstrip
chars are removed. Note that chars is not a prefix: all combinations of its value are removed:
Parameters
ParameterDescriptioncharsstring; or None;
default is None
The characters to remove, or all whitespace if None.
partition
sep and returns the resulting partition as a three-element tuple of the form (before, separator, after). If the input string does not contain the separator, partition returns (self, ”, ”).
Parameters
ParameterDescriptionsepstring;
required
The string to split on.
removeprefix
prefix, returns a new string with the prefix removed. Otherwise, returns the string.
Parameters
ParameterDescriptionprefixstring;
required
The prefix to remove if present.
removesuffix
suffix, returns a new string with the suffix removed. Otherwise, returns the string.
Parameters
ParameterDescriptionsuffixstring;
required
The suffix to remove if present.
replace
old have been replaced with new, optionally restricting the number of replacements to count.
Parameters
ParameterDescriptionoldstring;
required
The string to be replaced.
newstring;
required
The string to replace with.
countint;
default is -1
The maximum number of replacements. If omitted, or if the value is negative, there is no limit.
rfind
sub is found, or -1 if no such index exists, optionally restricting to [start:end], start being inclusive and end being exclusive.
Parameters
ParameterDescriptionsubstring;
required
The substring to find.
startint; or None;
default is 0
Restrict to search from this position.
endint; or None;
default is None
optional position before which to restrict to search.
rindex
sub is found, or raises an error if no such index exists, optionally restricting to [start:end], start being inclusive and end being exclusive.
Parameters
ParameterDescriptionsubstring;
required
The substring to find.
startint; or None;
default is 0
Restrict to search from this position.
endint; or None;
default is None
optional position before which to restrict to search.
rpartition
sep and returns the resulting partition as a three-element tuple of the form (before, separator, after). If the input string does not contain the separator, rpartition returns (”, ”, self).
Parameters
ParameterDescriptionsepstring;
required
The string to split on.
rsplit
sep as the separator, optionally limiting the number of splits to maxsplit. Except for splitting from the right, this method behaves like split().
Parameters
ParameterDescriptionsepstring;
required
The string to split on.
maxsplitint;
default is unbound
The maximum number of splits.
rstrip
chars are removed. Note that chars is not a suffix: all combinations of its value are removed:
Parameters
ParameterDescriptioncharsstring; or None;
default is None
The characters to remove, or all whitespace if None.
split
sep as the separator, optionally limiting the number of splits to maxsplit.
Parameters
ParameterDescriptionsepstring;
required
The string to split on.
maxsplitint;
default is unbound
The maximum number of splits.
splitlines
Parameters
ParameterDescriptionkeependsbool;
default is False
Whether the line breaks should be included in the resulting list.
startswith
sub, otherwise False, optionally restricting to [start:end], start being inclusive and end being exclusive.
Parameters
ParameterDescriptionsubstring; or tuple of string s;
required
The prefix (or tuple of alternative prefixes) to match.
startint; or None;
default is 0
Test beginning at this position.
endint; or None;
default is None
Stop comparing at this position.
strip
chars are removed. Note that chars is neither a prefix nor a suffix: all combinations of its value are removed:
Parameters
ParameterDescriptioncharsstring; or None;
default is None
The characters to remove, or all whitespace if None.