You are here : python_2 -> string

string

string.capitalize() Capitalizes first letter of string.
string.center() Returns a space-padded string with the original string centered to a total of width columns.
string.count() Counts how many times str occurs in string or in a substring of string if starting index beg and ending index end are given.
string.decode() Decodes the string using the codec registered for encoding. encoding defaults to the default string encoding.
string.encode() Returns encoded string version of string; on error, default is to raise a ValueError unless errors is given with 'ignore' or 'replace'.
string.endswith() Determines if string or a substring of string (if starting index beg and ending index end are given) ends with suffix; returns true if so and false otherwise.</p>
string.expandtabs() Expands tabs in string to multiple spaces; defaults to 8 spaces per tab if tabsize not provided.
string.find() Determine if str occurs in string or in a substring of string if starting index beg and ending index end are given returns index if found and -1 otherwise.
string.index() Same as find(), but raises an exception if str not found.
string.isalnum() Returns true if string has at least 1 character and all characters are alphanumeric and false otherwise.
string.isalpha() Returns true if string has at least 1 character and all characters are alphabetic and false otherwise.
string.isdecimal() Returns true if a unicode string contains only decimal characters and false otherwise.
string.isdigit() Returns true if string contains only digits and false otherwise.
string.islower() Returns true if string has at least 1 cased character and all cased characters are in lowercase and false otherwise.
string.isnumeric() Returns true if a unicode string contains only numeric characters and false otherwise.
string.isspace() Returns true if string contains only whitespace characters and false otherwise.
string.istitle() Returns true if string is properly "titlecased" and false otherwise.
string.isupper() Returns true if string has at least one cased character and all cased characters are in uppercase and false otherwise.
string.join() Merges (concatenates) the string representations of elements in sequence seq into a string, with separator string.
string.len() Returns the length of the string
string.ljust() Returns a space-padded string with the original string left-justified to a total of width columns.
string.lower() Converts all uppercase letters in string to lowercase.
string.lstrip() Removes all leading whitespace in string.
string.maketrans() Returns a translation table to be used in translate function.
string.max() Returns the max alphabetical character from the string str.
string.min() Returns the min alphabetical character from the string str.
string.replace() Replaces all occurrences of old in string with new or at most max occurrences if max given.
string.rfind() Same as find(), but search backwards in string.
string.rindex() Same as index(), but search backwards in string.
string.rjust() Returns a space-padded string with the original string right-justified to a total of width columns.
string.rstrip() Removes all trailing whitespace of string.
string.split() Splits string according to delimiter str (space if not provided) and returns list of substrings; split into at most num substrings if given.
string.splitlines() Splits string at all (or num) NEWLINEs and returns a list of each line with NEWLINEs removed.
string.startswith() Determines if string or a substring of string (if starting index beg and ending index end are given) starts with substring str; returns true if so and false otherwise.
string.strip() Performs both lstrip() and rstrip() on string
string.swapcase() Inverts case for all letters in string.
string.title() Returns "titlecased" version of string, that is, all words begin with uppercase and the rest are lowercase.
string.translate() Translates string according to translation table str(256 chars), removing those in the del string.
string.upper() Converts lowercase letters in string to uppercase.
string.zfill() Returns original string leftpadded with zeros to a total of width characters; intended for numbers, zfill() retains any sign given (less one zero).