擅长:python、mysql、java
<p>不完全回答你的问题,但是这个解决方案使用标准字典。你知道吗</p>
<pre><code>def group_by_owners(files):
grouped_files = {}
for key, value in sorted(files.items()):
grouped_files.setdefault(value, []).append(key)
return grouped_files
#prints {'Stan': ['Code.py'], 'Randy': ['Input.txt', 'Output.txt']}
</code></pre>
<p>我的答案基于一个例子:<a href="https://stackoverflow.com/questions/15751979/grouping-python-dictionary-keys-as-a-list-and-create-a-new-dictionary-with-this">StackOverflow</a></p>