String Methods Flashcards
str.capitalize()
Return a copy of the string with its first character capitalized and the rest lowercase.
str.casefold()
Return a case folded copy of the string.
str.center()
Return a centered string
str.count()
Returns the number of times a value occurs in a string.
str.encode()
Returns an encoded version of the string.
str.endswith()
Returns true if the string ends with specified value.
str.expandtabs()
Sets the tab size of the string
str.find()
Searches a string for a value and returns the position where it was found.
str.format()
Formats specified values in a string.
str.format_map()
Formats specified values in a string.
str.index()
Searches a string for a specified value and returns it’s position
str.isalnum()
Returns true if all characters are alpha numeric.
str.isalpha()
Returns true if all characters are letters.
str.isdecimal()
Returns true if all characters are decimals.
str.isdigit()
Returns true if all characters are digits.
str.isidentifier()
Returns true if string is an identifier.
str.islower()
Returns true if all characters are lower case.
str.isnumeric()
Returns true if all characters are numeric.
str.isprintable()
Returns true if all characters are printable.
str.isspace()
Returns true if all characters are white space.
str.istitle()
Returns true if the string follows the rules of a title.
str.isupper()
Returns true if all characters are upper case.
str.join()
Joins the elements of an iterablevto the end of the string.
str.ljust
Returns a left justified version of the string.
str.lower()
Converts a string to lowercase.
str.lstrip()
Returns a left stripped version of the string.
str.maketrans()
Makes a translation table to be used in translations.
str.partition()
Returns a triple where the string is split into three parts.
str.replace()
Returns a string where a value is replaced with a different value.
str.rfind()
Searches for the last instance of a value and returns it’s position.
str.rindex()
Searches for a value and returns it’s last occurrence.
str.rpartition()
Returns a triple with the string in three parts.
str.rsplit()
Splits the string at specified separator and returns a list.
str.rstrip()
Return a right trimmed string.
str.split()
Splits a string at separator and returns a list.
str.splitlines()
Splits string at line breaks and returns a list.
str.startswith()
Returns true if a string starts with a specified value.
str.swapcase()
Swaps upper and lower case,
str.title()
Converts the first letter of each word to a capital.
str.translate()
Returns a translated string.
str.upper()
Converts a string to all upper case.
str.zfill()
Fills a string with a specified number of zeros at the end.