table of Contents
Tuple built-in method
What is the tuple (tuple): not only desirable to change the list, create a tuple was written dead
Role: to create a tuple was written dead
:( spaced manner defined) within the plurality of elements with a comma (which may be of any data type)
If only one element tuple must have a comma
Instructions
- Index values
- Index sliced
- for loop
- Member operator
- len length
- index acquisition element index
- count count
Ordered or unordered
Ordered
Variable or immutable
There is not this say
Defined Ganso - "small memory -" Write dead
Dictionary built-in method
effect
Storing a plurality of data, each data having a description of
Defined way
{} Are separated by commas plurality of keys within key (descriptive sense, not the variable data type): value of the value (of any data type) of
Use
- Press the key value / modified value by key
- Add value, not just to add, modify it there
- for loop
- Member operator
- len length
- keys/values/items
- get get (no return None, can be given a default value
- update update (equivalent to the list in the extend)
- fromkeys
- setdefault (add only not modify)
Ordered or unordered
Disorderly
Variable or immutable
variable
Hash / hash table to store data
Compared list, hash tables, insert / delete data faster
- First, the key did hashing (hash can can handle all data types): Mersenne Twister (pseudo-random number generation) -> by hashing he can generate a sequence for each key (never repeat the same thing hashed into the same result)
- Hash function sequence just generated (pure digital), in addition to pure digital modulo 9 (0,1,2,3,4,5,6,7,8)
A collection of built-in method
What is the set: intersection / union / complement / set difference
effect
- For the calculation
- Deduplication
- Out of order - "a hash-based implementation
Defined way
{} The plurality of elements separated by commas (variable data types may not be)
Empty dictionary
s = {}
empty set
s = set {}s = { 'a', ' a', 'a', 'a', 1, 'v', 2, 2, 'c', 3, 3, 4, 5, 6} # for digital purposes, not will be out of order; but for others, it is scrambled
print (s) # {1, 2, 'a', 'c', 3, 4, 5, 6, 'v'}Instructions
Union
print(pythoners | linuxers)
Intersection
print(pythoners & linuxers)
Difference set
print(pythoners - linuxers)
Complement
print(pythoners ^ linuxers)
add
pythoners.add('oscar')
pop delete a random
pythoners.pop()
Ordered or unordered
Disorderly
Variable or immutable
variable
Data Type Summary
Number of stored-value
A stored value: integer / floating point / string
stored plurality of values: a list / tuple / dictionary / collection
Ordered or unordered
Ordered: string / list / tuple (sequence type)
unordered: dictionary / collection
Variable or immutable
Variable: List / dictionary / set
immutable: integer / floating point / string / tuple
Copy depth (only for variable data type)
Copy depth
copy
When y is a copy of the object x, if x is immutable, changes x y unchanged; if x is a variable type, x becomes y changes.
Shallow copy
If list1 list2 shallow copy of the object, the immutable elements within list1 changed, list2 unchanged; if the variable element in list1 changed, the change will follow list2.
Deep copy
If list1 list2 is deep copy of the object, the immutable elements within list1 changed, list2 unchanged; if the variable element in list1 changed, list2 not change, i.e. list1 list2 never change because of change.