Retain all entries except for one key python

后端 未结 7 591
情书的邮戳
情书的邮戳 2020-12-10 10:16

I have a python dictionary. Just to give out context, I am trying to write my own simple cross validation unit.

So basically what I want is to get all the values exc

7条回答
  •  被撕碎了的回忆
    2020-12-10 10:33

    Also, as a list comprehension using sets:

    d = dict(zip(range(9),"abcdefghi"))
    blacklisted = [2,5]
    outputs = [d[k] for k in set(d.keys())-set(blacklisted)]
    

提交回复
热议问题