python learning records 7 ----------- dictionary directory

Key is the dictionary {:} stored value, defined by the braces {}, when used as a general-purpose "in the brackets [] + key" used; key only immutable data types: plastic, string, Yuan group.

-------------------------------------------------- variable with the data type immutable ----------------------------------------

Variable types: lists, dictionaries.

Immutable data types: plastic, string, a tuple.

-----------------------------------------------------------------------------------------------------------------------

Is defined: dir = { 'name': 'fangxs', 'age': 18, 'sex': 'man'}

Call: print (dir [ 'name'])

Key can be integer, or tuple:

dir = {1:'fangxs',2:'age',('name','age'):(1,2)}

print (dir [1]) # output fangxs

print (dir [( 'name', 'age')]) # output (1,2)

Guess you like

Origin www.cnblogs.com/fangxiaosheng/p/11566969.html