>>> dict = {} >>> dict {} >>> dict['name']='syw' >>> dict['age']=18 >>> dict['school']='stzyjsxy' >>> dict {'name': 'syw', 'age': 18, 'school': 'stzyjsxy'}
>>> dict0 = dict.copy() >>> dict0 {'name': 'syw', 'age': 18, 'school': 'stzyjsxy'}
>>> dict0 = dict.copy() >>> dict0 {'name': 'syw', 'age': 18, 'school': 'stzyjsxy'} >>> dict1.fromkeys(b) {'key-0': None, 'key-1': None, 'key-2': None, 'key-3': None, 'key-4': None, 'key-5': None} >>> dict1.fromkeys(b,2) {'key-0': 2, 'key-1': 2, 'key-2': 2, 'key-3': 2, 'key-4': 2, 'key-5': 2} >>> dict1.fromkeys(b,[1,2]) {'key-0': [1, 2], 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2], 'key-5': [1, 2]} >>> dict1 {} >>> dict1 = dict1.fromkeys(b,[1,2]) >>> dict1 {'key-0': [1, 2], 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2], 'key-5': [1, 2]}
>>> dict.get('name') 'syw'
>>> dict.items() dict_items([('name', 'syw'), ('age', 18), ('school', 'stzyjsxy')])
>>> dict.keys() dict_keys(['name', 'age', 'school']) >>> dict.values() dict_values(['syw', 18, 'stzyjsxy'])
>>> dict1 {'key-0': [1, 2], 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2], 'key-5': [1, 2]} >>> dict {'name': 'syw', 'age': 18, 'school': 'stzyjsxy'} >>> dict.update(dict1) >>> dict { 'name': 'syw', 'age': 18, 'school': 'stzyjsxy', 'key-0': [1, 2], 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2], 'key-5': [1, 2] }
>>> dict {'name': 'syw', 'age': 18, 'school': 'stzyjsxy', 'key-0': [1, 2], 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2], 'key-5': [1, 2]} >>> dict.pop('key-0') [1, 2] >>> dict {'name': 'syw', 'age': 18, 'school': 'stzyjsxy', 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2], 'key-5': [1, 2]}
>>> dict {'name': 'syw', 'age': 18, 'school': 'stzyjsxy', 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2], 'key-5': [1, 2]} >>> dict.popitem() ('key-5', [1, 2]) >>> dict {'name': 'syw', 'age': 18, 'school': 'stzyjsxy', 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2]}
>>> dict {'name': 'syw', 'age': 18, 'school': 'stzyjsxy', 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2]} >>> dict.setdefault('class','21WeChat') '21WeChat' >>> dict {'name': 'syw', 'age': 18, 'school': 'stzyjsxy', 'key-1': [1, 2], 'key-2': [1, 2], 'key-3': [1, 2], 'key-4': [1, 2], 'class': '21WeChat'}
|