代码:
dict_data = {"a":"1", "b":2} dict_data["a"] = 2 dict_data[2] = "b" print(dict_data) print(dict_data.keys()) print(dict_data.values()) print(dict_data.get("a")) dict_data.clear()
运行结果:
{'a': 2, 'b': 2, 2: 'b'} dict_keys(['a', 'b', 2]) dict_values([2, 2, 'b']) 2 {}