day07 finishing
Shopping Cart structure
goods = goods_dic[goods_choice]
if goods in goods_car:
goods_car[goods] += 1
else :
goods_car[goods] = 1
Tuple built-in method
What is a tuple: only desirable, can not change the list, create a tuple was written dead
effect
Creating a tuple was written dead
Defined way
(Spaced apart) within the plurality of elements with a comma (which may be of any data type)
Note: 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
dictionary
effect
Storing a plurality of data, each data having a description of
Defined way
{} The plurality of keys separated by commas key (descriptive sense, not the variable data), value (of any data type)
Variable == -> not hash, immutable -> == hashable
Instructions
#### in accordance with the key values
print(dic['b'])
Add value, not to modify
dic['b'] = 4
for loop
Member operator
len length
keys/values/items
for snf, sfkjjs in dic.items (): # unzip
print(snf,sfkjjs)
get
Obtain
update
Dictionary update overlay, increase
fromkeys
Get key value from the list, value is None
setdefault
Dictionary increase key, value
Disorderly
variable
set
What is the set is a collection of multiple data types (non-variable) consisting of a whole
effect
Calculates, and cross up
Deduplication
Out of order
Defined way
{} The plurality of elements separated by commas (not a variable data type)
Keyword set
Instructions
And |
cross&
Poor -
Complement ^
add()
Disorderly
variable
Data Type Summary
Number of stored-value
Save a value: plastic, floating point, character
A plurality of stored values: List / tuple / dictionary / collection
Order-disorder
Ordered: strings, lists, tuples
Disorder: dictionaries, collections
Variable immutable
Variable: lists, dictionaries, collections
Immutable: integer, floating point, string, a tuple
The main contents copy depth
Lt2 is 1. When the copy of the object lt1, immutable data changes within lt1, lt2 changes, changes in the internal lt1 variable data, variable lt2
Shallow copy
2. When lt2 is the copy of the object lt1, immutable data changes within lt1, lt2 does not change, changes within lt1 variable data, variable lt2
Deep copy
3. When the copy of the object is lt2 lt1 of immutable data changes within lt1, lt2 does not change, changes within lt1 variable data, unchanged lt2