对字典中键值的整数列表进行排序 python

sort list of integers that are value to a key in dictionary python

我有一个视频中的 300 帧,格式为 name_numberofFrame,我创建了一个字典,其中的键作为名称,键的值作为帧数的列表,但是这个列表没有排序,我希望它是排序以执行一些其他操作。 请给我一种方法来排序该列表?

没那么难。您可以访问此字典中的每个值并对其进行排序。像这样:

a={'a':[4,2,1], 'v':[41,5,1]}

for i,j in a.items():
    a[i]=sorted(a[i])

print(a)

输出:

{'a': [1, 2, 4], 'v': [1, 5, 41]}

希望这就是您要找的。