1, capitalize-- the first letter of the string converted to uppercase
a='attention' b=a.capitalize() print(b)
2, casefold-- string in all uppercase letters to lowercase letters (uppercase first letter)
a='ABCention' b=a.casefold() print(b)
3, lower-- string in all capital letters to lower case letters (including initials)
a='aBCention' b=a.lower() print(b)
4, the character is inserted into center-- filled to its set length of the space bar
a='aBCention' b=a.center(20,'&') print(b)
5, subsequence startswith / endwith-- determines what string end, wherein, the control may start and end the start position and end position, wherein the start and end may be empty.
a='aBCention' b=a.endswith('n') print(b)
6, format-- format, the string value from placeholders alternative
a='aBCention {0} is {1} years old' b=a.format( 'zhangsan',13) print(b)
NOTE: If the string is not placeholders can be replaced both in the order of occurrence.
a='aBCention {0} is {1} years old' b=a.format( 'zhangsan',13) print(b)
7, format_map-- format, placeholders have been replaced dictionary.
a='aBCention {name} is {age} years old' b=a.format_map( {'name':'zhangsan','age':13}) print(b)
a = 'sadwefda' b = a.index('f') print(b)
9, expandtabs () - punctuation, the string may be output in tabular form (containing a string \ t and \ n punctuation to it separately, brackets 30 indicates the length of a space separated)
a = 'sadw\tefda\n*\n&*^^\n*%^$$\tG\tYFYFTYFDT' b = a.expandtabs(30) print(b)
10, isalnum () - determines whether a string contains only letters and numbers
a = 'sadw\tefda\n*\n&*^^\n*%^$$\tG\tYFYFTYFDT' b = a.isalnum() print(b)
11, isalpha () - determines whether the character string contains only
a = 'sadYFYFTYFDT' b = a.isalpha() print(b)
12, isdecimal () / test.isdigit () - determines whether the value of the current variable is a number, the difference between them is isdigit () may be the identification number of different languages, isdecimal () recognized only Arabic numerals
test = '01234' v1 = test.isdecimal() v2 = test.isdigit() print(v1,v2)
test = 'johnny' v = test.swapcase() print(v)
14, islower () - determines whether all characters in a string are lowercase
test = 'johnny' v = test.islower() print(v)
15, isnumeric () - determines the genuineness of the digital current string
test = '四' v1 = test.isnumeric() print(v1)
= test ' johnny ' v = test.isprintable () print (v)
17, isspace () - determines whether the string is a space full
test = ' ' v = test.isspace() print(v)
test = 'Johnny is good boy' v = test.istitle() print(v)
19, title () - within the current string (title) the contents of the first letter capitalized
test = 'johnny is good boy' v = test.title() print(v)
20, join () - each element string according to a specified splicing delimiter
test = 'johnny' t = ' ' v = t.join(test) print(v)
21, usage of ljust () and the rjust (): the string left justified, right justified output, wherein a character may be transferred fillchar