我想将键更改为 python 字典中的值,但原始字典中的值不是唯一的。
这是我所拥有的:
year_person = {2000: ‘Linda’, 2001: ‘Ron’, 2002: ‘Bruce’, 2003: ‘Linda’, 2004: ‘Bruce’, 2005 ‘Gary’, 2006: ‘Linda’}
这就是我想将其更改为:
person_year = {‘Linda’: 2000, ‘Ron’: 2001, ‘Bruce’: 2002, ‘Linda’, 2003: ‘Bruce’, 2004 ‘Gary’, 2005: ‘Linda’: 2006}
当我尝试使用 for 循环转换它时,每个人只有一对匹配。