- Common method list append, insert, extend, pop, remove
- Method count two tuples, index
- Commonly used methods, and the escape count string, find, index, replace, split, \ n, \ t, \ ', \\, r' '
- encode decode encoding rules
- dir () when parameters, return parameter attributes, list of methods
List method
increase
Append: append (value)
Insert: insert (index value)
Append: extend (sequence type) # string taken out one by one is added later
delete
pop (index) # delete the last default, can not fill sliced
remove (value) # If duplicates, delete the first
del list name [index] # index can fill a slice, delete multiple
clear () # Clear List
change
List name [index] = value
check
index (value, index starting point) # returns the value of the index of the first occurrence, from the index starting point query (the default is 0), if there is an error
count (value) Returns the number of values appear #
Other methods
List 1 = 2.Copy list ()
sort () # positive sequence arrangement
reverse () # reverse arrangement (not reverse order)
Tuple method
Tuples are immutable, only two ways to facilitate the search data tuple
index (value, index starting point) # returns the value of the index of the first occurrence, from the index starting point query (the default is 0), if there is an error
count (value) Returns the number of values appear #
String Methods
Although the strings are immutable, but can be achieved by the process returns CRUD new object
increase
Symbol '+' splice string #
delete
replace ( 'is replaced by the value of' 'replacement value', the number of replacement) # deleted when the replacement value of quotation marks is not filled
change
upper () # change uppercase lowercase
lower () # uppercase to lowercase
strip () # remove trailing spaces
lstrip () # remove only spaces on the left
rstrip () # remove only spaces on the right
capitalize () # capitalize the first letter
title () # capitalize the first letter of each word
split (value) specified value # cutting string, returns a list of
check
count (value) Returns the value of the number of occurrences #
index (value, index starting point) # returns the value of the index of the first occurrence, from the index starting point query (the default is 0), if there is an error
find (value, index starting point) # returns the index from the index starting point query (the default is 0), or -1 if there
isdigit () # judge is not a pure numbers, all numbers within a string and returns True, otherwise False
isalpha () # judge is not a pure character, returns bool
endsWith (value) # string is determined not to end the value
startsWith (value) # string is determined not start with the value
islower () # Analyzing pure lowercase
isupper () # judge uppercase
String escaping and encoding
Plus character in front of \ character represents the character itself is no longer the meaning of the ASCII character codes can not be displayed, there are common under
\ N newline
\ T horizontal tab
\ B Backspace # equivalent pressed the delete key
\ R carriage return, the current position to the end of the content to the beginning of the line (alternatively foregoing summary)
Representatives \\ \
\ 'For a single quote', the same "and other symbols could be so output
\ 0 represents a null character
\ A system beep
If in python escaped string to be removed, just in front of the string with r, such as: r '\ abcdefg'
String encoding
Encoding (encode), default to 'utf-8'
Decoding (decode)