Digital type built-in method
Integer
Role : Description of age, id, etc.
Defined method : x = 10
Built-in method :
No built-in method 1, only the arithmetic and compare operations
Stored value or a value of more than one person : a value
Ordered or disordered : they not say that # ordered: an index; disorder: None Index
Variable or non-variable : immutable
Float
Role : Salary Description
Defined method : x = 1.11
Built-in method :
Arithmetic and comparison operations
A plurality of stored value or values : a value
Ordered or disordered : It did not even say
Variable or non-variable : immutable
String type built-in method
Role : Description name, gender
Defined way :
name = 'nick'
# \n 换行
# \t 缩进,4个空格
# \r+end='' 覆盖上一次打印
name = r'\n\ta' # 取消\n和\t的作用
name = '\\n\\ta' # 取消\n和\t的作用
Priority grasp
- Index values
- slice
- strip remove blank ()
- split Segmentation
- Length len
- Member operator in or not in
- for loop
Need to know
- upper / lower case
- startswith / endswith start with what / what end
- rstrip / lstrip the right to remove blank / remove left blank
- rsplit right cutting
- isdigit / isalpha purely digital / plain letters
- join the connection string array
- replace substitute
To understanding
- find / rfind / index / rindex / count from left to right to find / right to left to find / count
- capitalize / swapcase / title word capitalized / reverse capitalization / capitalize the first letter of each word
- center / ljust / rjust / zfill Center / Left / right of abode
- is series (really understand)
- A plurality of stored value or values: one
- Ordered or disordered: Ordered
- The variable is immutable: immutable
Ordered or disordered : orderly
The index is ordered, no index is disorderly
Variable or non-variable : immutable
Id value becomes constant is a variable type; variable id value variable is immutable
List type built-in method
Role : that description more interested in
定义:hobby_list = ['play','swimming','dancing','666']
Built-in method :
Priority grasp :
- Index values
- slice
- Length len
- Member operator in / not in
- for loop
- del Delete
- Add append
You need to know :
1.count count
2.extend extended list
3.clear Clear
4.copy Copy
5.pop default delete the last
6.index Index
7.insert insert
8.remove removed
9.reverse reversal
Stored value or a plurality of values : a plurality of values
Disorderly or orderly : Ordered
Variable or immutable : variable
Ancestral type built-in method
Role : more equipment, more loving, and more courses, and even more girlfriend
Is defined : in () may have a plurality of values of any type, a comma-separated elements
Built-in method :( same list)
Priority grasp:
- Index values
- slice
- Length len
- Member operator in / not in
- for loop
- count count
- index index
Stored value or a plurality of values : a plurality of values
Disorderly or orderly : Ordered
Variable or non-variable : immutable
Variable is a list of reasons: the memory address corresponding to the index value may be varied
Tuples can not become the reason is: the index of the corresponding memory address values can not change, or conversely, as long as the memory address corresponding to the index value has not changed, then the tuple is never changed.
A dictionary built-in methods
Action : a plurality of stored values, but each has a value of a corresponding key, key values described functions. It is used for different states when the stored value indicates, for example, the value stored there name, age, height, weight, hobbies.
Is defined : {} within the plurality of elements spaced apart by commas, each element is a key: in the form of value, the data value may be any type, but generally should be a string type key, but the key must be immutable.
Dictionary built-in methods :
Priority grasp :
1. Press the key access Found: deposit may be desirable
2. length len
3. The members of the operations in and not in
4. Delete del
The key keys (), the value of values (), on the key-value items ()
6.for cycle
You need to know :
1.copy Copy
2.pop default delete the last
3.popitem early when dictionaries are unordered, random deleted, but because of the underlying optimization python3 the dictionary, let's look at the dictionary seemingly orderly, so the default delete the last
4.get If so, it returns a true value; if not, the default return None, you can also specify a return
5.setdefault there will remain unchanged, no added value is entered,
6.update dict2 dictionary of key / value pairs in the update to the dict
7.fromkeys quickly create a new dictionary
Stored value or a plurality of values : a plurality of values
Disorderly or orderly : disordered
Variable or immutable : variable
Set type built-in method
Effect : the relationship for assembly operations, since the elements in the set unordered collection of elements and can not be repeated, and therefore can be set to the weight, but will re-set to disrupt the order of the original elements.
Is defined : {} within the plurality of elements spaced apart by a comma, each element must be immutable.
Built-in method
Priority grasp
- | Union, union
- & Intersection, intersection
- -差集、difference
- CROSS ^ (symmetric) difference sets, symmetric_difference
To understanding
1.pop randomly deleted
2.update update
3.clear Empty
4.copy Copy
5.remove removed (not being given)
6.discard removed (not without error)
Stored value or a plurality of values : a plurality of values, and is immutable.
Disorderly or orderly : disordered
Variable or immutable : Variable Data Type