.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
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
find
sub is found, or -1 if no such index exists, optionally restricting to [start:end], start being inclusive and end being exclusive.
Parameters
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
| Parameter | Description |
|---|---|
args | 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
isalnum
isalpha
isdigit
islower
isspace
istitle
isupper
join
Parameters
| Parameter | Description |
|---|---|
elements | required |
lower
lstrip
chars are removed. Note that chars is not a prefix: all combinations of its value are removed:
Parameters
| Parameter | Description |
|---|---|
chars | string; 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
| Parameter | Description |
|---|---|
sep | required The string to split on. |
removeprefix
prefix, returns a new string with the prefix removed. Otherwise, returns the string.
Parameters
| Parameter | Description |
|---|---|
prefix | required The prefix to remove if present. |
removesuffix
suffix, returns a new string with the suffix removed. Otherwise, returns the string.
Parameters
| Parameter | Description |
|---|---|
suffix | required The suffix to remove if present. |
replace
old have been replaced with new, optionally restricting the number of replacements to count.
Parameters
| Parameter | Description |
|---|---|
old | required The string to be replaced. |
new | required The string to replace with. |
count | 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
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
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
| Parameter | Description |
|---|---|
sep | 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
| Parameter | Description |
|---|---|
sep | required The string to split on. |
maxsplit | int; or None; default is None The maximum number of splits. |
rstrip
chars are removed. Note that chars is not a suffix: all combinations of its value are removed:
Parameters
| Parameter | Description |
|---|---|
chars | string; 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
| Parameter | Description |
|---|---|
sep | required The string to split on. |
maxsplit | int; or None; default is None The maximum number of splits. |
splitlines
Parameters
| Parameter | Description |
|---|---|
keepends | 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
strip
chars are removed. Note that chars is neither a prefix nor a suffix: all combinations of its value are removed:
Parameters
| Parameter | Description |
|---|---|
chars | string; or None; default is None The characters to remove, or all whitespace if None. |