1. Remove Space
Strip (self, Chars=none)
Lstrip (self, chars=none)
Rstrip (self, chars=none)
2. Uppercase and lowercase conversions in strings
Convert lower (self) to lowercase
Convert upper (self) to uppercase
Swapcase (self) case-sensitive interchange
Capitalize (self) Capitalize first letter
Capitalize (self) first letter converted to uppercase, remaining lowercase
Title (self) The first letter of the word is converted to uppercase
3. Find string
Find (self, sub, Start=none, End=none) finds string position, cannot find return-1
Index (self, sub, start=none, End=none) Find string position, error not found
RFind (self, sub, start=none, End=none) find from the right
Count (self, sub, Start=none, End=none) How many of the specified characters are searched
4. String alignment
Rjust (self, width, fillchar=none) Take fixed length right alignment, left not enough space to complement
Ljust (self, width, fillchar=none) take fixed length left aligned, right not enough space to complement
Center (self, width, fillchar=none) Take fixed length middle alignment, left or right not enough space to complement
5. String judgment
Whether the Isupper (self) string is all uppercase
Islower (self) string is all lowercase
StartsWith (self, prefix, Start=none, End=none) whether a string begins
EndsWith (self, suffix, start=none, end=none) whether a string has ended
Whether the isalnum (self) is all letters or numbers
Whether the isalpha (self) is full letter
Whether the isdigit (self) is a full number
6. String segmentation
Split (self, sep=none, Maxsplit=none) separated by a symbol, default space
7. String connection
Join (self, iterable) connect a tuple or list
>>>var_list = [' Tom ', ' David ', ' John ']
>>>a = ' _ '
>>>print A.join (var_list)
>>>tom_david_john
8, the TAB key fills the space, the tab is denoted by \ t
Expandtabs (self, tabsize=none) Tab key fills a specified number of spaces
9. String substitution
Format (self, *args, **kwargs) replaces placeholder {0} {1} ...
Replace (self, old, new, Count=none) replaces the specified number of old to new, starting from the left
This article is from the "10893237" blog, please be sure to keep this source http://10903237.blog.51cto.com/10893237/1973881
Python string manipulation methods Daquan