dictionary in python add and get dic = {} dic[1] = 'b' print(dic[1]) print(1 in dic) 结果 b True iterate >>> a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'} >>> for key in a_dict: ... print(key) ... color fruit pet