Python辞書のキーと値のペアの反転方法

辞書の派生:

 に相当:

dict={"zhangsan":'12',"lisi":'13',"wangwu":'15'}

inverse_dic={}

for key,val in dict.items():

  inverse_dic[val]=key

 

おすすめ

転載: blog.csdn.net/Growing_hacker/article/details/103804443