【发布时间】:2022-11-15 01:52:26
【问题描述】:
我有一本字典“A”,
A = {'Industry1':1, 'Industry2':1, 'Industry3':1, 'Customer1':1, 'Customer2':1, 'LocalShop1':1, 'LolcalShop2':1 }
A = {'Industry1': 1,
'Industry2': 1,
'Industry3': 1,
'Customer1': 1,
'Customer2': 1,
'LocalShop1': 1,
'LolcalShop2': 1}
我想按键名分组并为每个“类别”创建新字典,名称应该自动生成
预期产出
Industry = {'Industry1': 1,
'Industry2': 1,
'Industry3': 1,
}
Customer = { 'Customer1': 1,
'Customer2': 1,
}
LocalShop = { 'LocalShop1': 1,
'LolcalShop2': 1}
你们能给我一个实现这个输出的提示吗?
【问题讨论】:
标签: python dictionary