赞
踩
dicts[new_name] = dicts.pop(old_name)
例子:
- dicts = {
- "xx": 1,
- "zz": 2,
- "yy": 3
- }
- dicts['yy'] = dicts.pop('xx')
- print(dicts)
结果:
{'zz': 2, 'yy': 1}
dicts[new_name] = value
例子:
- dicts = {
- "xx": 1,
- "zz": 2,
- "yy": 3
- }
- dicts["aa"] = 4
- print(dicts)
结果:
{'xx': 1, 'zz': 2, 'yy': 3, 'aa': 4}
del dicts[del_name]
例子:
- dicts = {
- "xx": 1,
- "zz": 2,
- "yy": 3
- }
- del dicts['xx']
- print(dicts)
结果:
{'zz': 2, 'yy': 3}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。