Answers for "python dict filter keys"

0

python filter a dictionary

d = dict(a=1, b=2, c=3, d=4, e=5)
print(d)
d1 = {x: d[x] for x in d.keys() if x not in ['a', 'b']}
print(d1)
Posted by: Guest on January-14-2021
0

filter dict with certain keys

>>> obj = { "a":1, "b":{"c":2,"d":3}}
>>> only(obj,["a","b.c"])
{'a': 1, 'b': {'c': 2}}
Posted by: Guest on June-22-2021

Python Answers by Framework

Browse Popular Code Answers by Language