String processing:
Name= ' Go die '
-Capitalize first letter capital
-Casefold all caps into lowercase
-Lower all uppercase to lowercase
-Center text centered
-Print (Name.center (20, ' * '))
Go die*******
-Count (G,start,end) The number of occurrences of the query character, start is the start position, end is the ending position
-Whether EndsWith (") ends with a character
-StartsWith () whether to start with a character
-Find () finds the index position of the subsequence: no Return-1
Index ()
-String formatting
end = ' I am: {0}; Age: {1}; Gender: {2} '
v = end.format (' Go ', +, ' OK ')
-Judging whether it is a number, kanji
Isalnum ()
Isalpha ()
-whether it is a representation
Isidentifier ()
-Whether all lowercase
Islower ()
-Capitalize all
Isupper ()
-whether to include printable characters
Isprintable ()
-Element stitching
name = ' Go '
V= ' _ '. Join (name)
li=[' fir ', ' sec ', ' thr ']
V2= ' _ '. Join (LI)
-Padding left and right
Name.rjust (20, ' * ')
-Replace
Replace ()
-Convert into bytes
Name.encode (encoding= ' utf-8 ')
**********************************************
int integer
Age=4
Age.bit_length () minimum number of digits
***********************************************
BOOL Boolean value
V=0
V= ""
V=[]
BOOL value is False
*************************************************
List lists
User_list = [' Li Quan ', ' Liu Yi ', ' Liu Kang ', ' peas ', ' dragons ']
-Additional append ()
-Clear Clear ()
-Shallow copy Copy
-Counts count ()
-Extended extend (' Tom ')
-Delete and get elements pop (1)
-Delete value remove (' Liu Yi ')
-Flip Reverse ()
-sorting sort () from small to large
Sore (reverse=true) from big to small
**********************************************
Tuple: The elements of a tuple are not modifiable
User_tuple = (' Alex ', ' Eric ', ' Seven ', ' Alex ')
-Get number User_tuple.count (' Alex ')
-Get index location
User_tuple (' seven ')
************************************************
Dictionary
DiC = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
-Empty Dic.clear ()
-Add, do not operate if present
Dic.setdefault (' K1 ', 11111)
-Bulk additions or modifications
Dic.update ({' K3 ': ' V3 ', ' K4 ': ' V4 '})
************************************************
S1 = {"Alex", ' Eric ', ' Tony ', ' Li Quan ', ' Li Quan 11 '}
S2 = {"Alex", ' Eric ', ' Tony ', ' Liu Yi '}
1.S1 exists in the S2, does not exist in the
v = s1.difference (S2)
Print (v)
# # # # # S1 exists, S2 does not exist, then clears the S1 and then re-replicates
S1.difference_update (S2)
Print (S1)
2.S2 exists in the S1, does not exist in the
v = s2.difference (S1)
Print (v)
3.S2 exists in the S1, does not exist in the
S1 exists in the S2, does not exist in the
v = s1.symmetric_difference (S2)
Print (v)
4. Intersection
v = s1.intersection (S2)
Print (v)
5. and set
v = s1.union (S2)
Print (v)
Python data structure