Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有有{key : []}格式的字典。我需要准备一个根据值的长度(列表的长度)排序的列表。实现这一目标的最佳方法是什么?
{key : []}
如果您正在寻找按长度排序的值,并假设 dict d:
d
lists_by_length = sorted(d.values(), key=len)
另请参阅按值对 Python 字典进行排序