我有以下三个整数值:
id # identifies the pair
entropy # gives entropy information
len # basicly the length of a string
现在我想存储许多这些值并选择总体熵最高且长度值超过的前 10 个n
from collections import defaultdict
d = defaultdict(list)
for id, entropy, len in generateValues:
d[id].append(entropy)
d[id].append(len)
# now get the top 10 values
这很容易做到吗?