擅长:python、mysql、java
<p>您可以使用以下代码:</p>
<pre><code>favorittForfattere={'Per':'Christie','Kari':'Ibsen','Liv':'Rowling','Ola':'Ibsen','Anne':'Allende', 'Jens':'Christie'}
dictionary={}
for i in favorittForfattere:
if favorittForfattere[i] not in dictionary:
dictionary[favorittForfattere[i]]=[]
dictionary[favorittForfattere[i]].append(i)
</code></pre>
<p>输出:</p>
<pre><code>{'Christie': ['Per', 'Jens'],
'Ibsen': ['Kari', 'Ola'],
'Rowling': ['Liv'],
'Allende': ['Anne']}
</code></pre>