Make an incomplete summary of the dictionaries in Python3.
There is no order in the dictionary.
>>> d={"Soam": 2,'Ham': 1,'eggs': 3}>>> list (D.keys ())#returns the key list for the dictionary['Soam','Ham','eggs']>>> list (D.items ())#returns a list of (Key,value) dictionaries[('Soam', 2), ('Ham', 1), ('eggs', 3)]>>> list (d.values ())#returns the value list of a dictionary[2, 1, 3]>>> D.update ({'Gyj': 4})#Merging of Dictionaries>>>d{'Soam': 2,'Ham': 1,'eggs': 3,'Gyj': 4}>>> forKeyinchD:#Dict can be iterated directly, unlike Java Print(Key,'\ t', D[key]) Soam2Ham1eggs3Gyj4
The keys in Dict can only be immutable objects.
Four ways to create Dict
>>> {'name':'Gyj',' Age': 45}{'name':'Gyj',' Age': 45}>>> d={}>>> d['name']='Gyj'>>> d[' Age']=45>>>d{'name':'Gyj',' Age': 45}>>> Dict (name='Gyj', age=45){'name':'Gyj',' Age': 45}>>> Dict ([('name','Gyj'),(' Age', 45)]){'name':'Gyj',' Age': 45}>>> Dict.fromkeys (['a','b'],0) {'a': 0,'b': 0}
The following are the ways to create dictionaries that are only supported by Python3:
>>> dict (Zip (['name','age'],['gyj ){'name''gyj') 'age': 45}
Python3 dict Incomplete summary