One. The characteristics of the dictionary. :
(1). The Python dictionary is unordered. (and the list is orderly) we can understand the dictionary as a set of key:value such a health value pair.
(2). The key of the Python dictionary is unique.
(3). Dictionaries can be nested in dictionaries, nested lists.
Eg: Define a dictionary. Perform basic operations on the dictionary.
1>>> dict = {2...' One':"1111",3...' Both':"2222",4...'three':"3333",5...'foure':"4444",6... }#Define a dictionary7>>>Print(dict)8{' Both':'2222','three':'3333','foure':'4444',' One':'1111'}9>>> doc2["fave"] ="5555" #IncreaseTen>>>Dict One{' Both':'2222','three':'3333','foure':'4444',' One':'1111','fave':'5555'} A>>> Dict.pop (" One")#Pop function Delete - '1111' ->>>Dict the{' Both':'2222','three':'3333','foure':'4444','fave':'5555'} ->>>deldict[" Both"]#del Delete ->>>Dict -{'three':'3333','foure':'4444','fave':'5555'} +>>> doc2["fave"] ="5" #Change ->>>Dict +{'three':'3333','foure':'4444','fave':'5'} A>>> Dict.get (" Four") at>>> Dict.get ("foure")#Not present in the dictionary will not error, but return none - '4444' ->>> dict["foure"]#not exist in the dictionary will be an error - '4444' ->>>" Four" inchDict - False in>>>" Four" not inchDict -True
View Code
Python (2) dictionary