删除字典内多个指定的键值
思路很简单,可以随意添加想移除的值
# print(x.shape)
Value = dict(a=1, b=2, c=3, d=4) # 先新建一个字典
print(Value, type(Value))
ignore = ['a', 'b'] # 准备剔除的键
for i in ignore:
del Value[i]
print(Value)
结果如下:
{'a': 1, 'b': 2, 'c': 3, 'd': 4} <cl
原创
2022-05-05 16:24:39 ·
553 阅读 ·
0 评论