Functions of the String Application Program Interface (API)
-
isalnum() Returns true if the string contains only alphabetic letters or digits and is at least one character in length. Returns false otherwise.
-
isalpha() Returns true if the string contains only alphabetic letters and is at least one character in length. Returns false otherwise.
-
isdigit()Returns true if the string contains only numeric digits and is at least one character in length. Returns false otherwise.
-
islower()Returns true if all of the alphabetic letters in the string are lowercase, and the string contains at least one alphabetic letter. Returns false otherwise.
-
isspace()Returns true if the string contains only whitespace characters and is at least one character in length. Returns false otherwise. (Whitespace characters are spaces, newlines (\n), and tabs (\t).
-
isupper()Returns true if all of the alphabetic letters in the string are uppercase, and the string contains at least one alphabetic letter. Returns false otherwise.
-
lower()Returns a copy of the string with all alphabetic letters converted to lowercase. Any character that is already lowercase, or is not an alphabetic letter, is unchanged.
- lstrip()Returns a copy of the string with all leading whitespace characters removed. Leading whitespace characters are spaces, newlines (\n), and tabs (\t) that appear at the beginning of the string.
-
lstrip(char) The char argument is a string containing a character. Returns a copy of the string with all instances of char that appear at the beginning of the string removed.
-
rstrip() Returns a copy of the string with all trailing whitespace characters removed. Trailing whitespace characters are spaces, newlines (\n), and tabs (\t) that appear at the end of the string.
-
rstrip(char)The char argument is a string containing a character. The method returns a copy of the string with all instances of char that appear at the end of the string removed.
-
strip() Returns a copy of the string with all leading and trailing whitespace characters removed.
-
strip(char) Returns a copy of the string with all instances of char that appear at the beginning and the end of the string removed.
-
upper() Returns a copy of the string with all alphabetic letters converted to uppercase. Any character that is already uppercase, or is not an alphabetic letter, is unchanged. The lower and upper methods are useful for making case-insensitive string comparisons. String comparisons are case-sensitive, which means that the uppercase characters are distinguished from the lowercase characters.
-
replace(old, new)The old and new arguments are both strings. The method returns a copy of the string with all instances of old replaced by new.
- startswith(substring) The substring argument is a string. The method returns true if the string starts with substring.