Python 将dict结构从值更改为键

Python 将dict结构从值更改为键,python,dataframe,dictionary,for-loop,key-value-store,Python,Dataframe,Dictionary,For Loop,Key Value Store,假设我有以下词典: my_dict = {'month': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'year': [2006, 2012, 2003, 2006, 2012, 2018, 2020, 2011, 2000, 2001, 2013, 2013]} 我怎样才能创建一个像这样的新词典 new_dict = {'1': '2006', '2': '2012', ..., '12': '2013'} 转换为字符串值: months = [st

假设我有以下词典:

my_dict = {'month': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'year': [2006, 2012, 2003, 2006, 2012, 2018, 2020, 2011, 2000, 2001, 2013, 2013]}
我怎样才能创建一个像这样的新词典

new_dict = {'1': '2006', '2': '2012', ..., '12': '2013'}
转换为字符串值:

months = [str(item) for item in my_dict['month']]
years = [str(item) for item in my_dict['year']]
dict(zip(months, years))

如果只是一个技术问题,OP似乎要求将字符串作为输出,而不是int
months = [str(item) for item in my_dict['month']]
years = [str(item) for item in my_dict['year']]
dict(zip(months, years))