Syntax - Tom Kleen
Python String Methods Quick GuideSyntaxActionLocating substringss.count(substring[, start[, end]])Count occurrences of?substring within ss.startswith(prefix[, start[, end]])True if?s?starts with?prefixs.endswith(suffix[, start[, end]])True if?s?ends with?suffixs.find(substring [,start [,end]])Find first occurrence of?substring?and return its index number; if not found, return -1s.index(<sub_str>)Same as find but raises ValueError if missing.s.rfind(substring [,start [,end]])Find the last (rightmost) occurrence of?substring?and return its index number; if not found, return -1s.rindex(<sub_str>)Same as rindex but raises ValueError if missings.splitlines(keepends=False)Splits on \n,\r,\r\n. Keeps them if keepends is True.Testing character categoriess.isalnum()True if?s?has only letters, digitss.isalpha()True if?s?has only alphabetic characterss.isdigit()True if?s?has only digitss.isspace()True if?s?has only whitespace charactersChanging cases.lower()Returns a lowercase copy of ss.upper()Returns an uppercase copy of ss.capitalize()Returns a copy of s with first letter in upper caseDetecting cases.islower()Returns True if all of the characters in s are lower case, False otherwises.isupper()Returns True if all of the characters in s are upper case, False otherwiseTrimmings.lstrip([chars])Returns a copy of s with whitespace (or?chars) removed from the left of ss.rstrip([chars])Returns a copy of s with whitespace (or?chars) removed from the right of ss.strip([chars])Returns a copy of s with whitespace (or chars) removed from both the left and right of s.Alignments.center(width)Returns a copy of s centered in a field of width spacess.ljust(width)Returns a string left justified in a field of width spacess.rjust(width)Returns a string right justified in a field of width spacesMiscs.replace (old, new[, count])Replace?old?(a substring) with?news.split([separator [,maxsplit]])split?s?using whitespace (or?separator) and return a list of substringss.join(iterable)Using?s?as a separator, stick together the strings in iterableNot string methods, but related functionsstr(int)Converts the integer to a corresponding stringord(s)Gives the Unicode value of s. s must be a single character. ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- counting occurrences for a finite set of words an
- text analysis with nltk cheatsheet
- practical file class xii computer science with
- lab manual python programming lab 6cs4 23 jnit
- introduction to python borenstein lab
- programming for engineers in python
- python count number of occurrences of a substring in string
- indexing and slicing
- list example counting occurrences of letters
- prof dipesh agrawal