‘’’
#取字典中的键值并转化为列表
key_list = list(dc.keys())
print(key_list)
#删除较近的元素
for i in key_list:
if i+2 in dc and i-2 in dc:
del dc[i-2]
del dc[i+2]
print(dc)
#按键值对排序并打印字典
for i in sorted (dc) :
print ((i, dc[i]), end =" ")