发布网友
共3个回答
热心网友
In [37]: dic
Out[37]: {'a': 'test', 'b': 10, 'c': 30, 'd': 50, 'e': 60, 'f': 100}
In [38]: [i for i in dic.values() if isinstance(i,int) and i>50]
Out[38]: [60, 100]
图片看不清的话看复制的
热心网友
key_list = d.keys()
result = []
for i in key_list:
try:
if d[i] > 90:
result.append(i)
else:
pass
except:
pass
print(result)
大于90的key就放到了result列表中了
热心网友
print([key for key in d if type(d[key]) in (int, float) and d[key] > 90])