# coding=utf8 dict_info = {"abc": 1, 1: "liuzhipeng"} for k, v in dict_info.items(): print "{key}->{value}".format(key=k, value=v) print dict_info.keys() print dict_info.values() print dict_info.items() dict_info.update(abc=3,name="liu",) print dict_info #输出 C:\Python27\python.exe C:/Users/Administrator/PycharmProjects/oldboy/lesson_3/test.py 1->liuzhipeng abc->1 [1, 'abc'] ['liuzhipeng', 1] [(1, 'liuzhipeng'), ('abc', 1)] {1: 'liuzhipeng', 'abc': 3, 'name': 'liu'}
来源:https://www.cnblogs.com/liuzhipenglove/p/7307700.html