- Remove more than one key from Python dict
- x = {'a': 5, 'b': 2, 'c': 3}
- x.pop('a', 'b')
- print x
- {'c': 3}
- x = {'a': 5, 'b': 2, 'c': 3}
- del x['a'], x['b']
- print x
- {'c': 3}
- >>> x={'a':5,'b':2,'c':3,1:'abc',2:'efg',3:'xyz'}
- >>> [k for k in x if type(k) == str]
- ['a', 'c', 'b']
- >>> for key in [k for k in x if type(k) == str]: del x[key]
- >>> x
- {1: 'abc', 2: 'efg', 3: 'xyz'}