字典(dict)删除元素, 能够选择两种方式, dict.pop(key)和del dict[key]. 代码 # -*- coding: utf-8 -*- def remove_key(d, key): r = dict(d) del r[key] return r x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0} x.pop(1) print x x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0} del x[1] print x x = {1: 2,…