我需要创建一个字典,其键是来自先前创建的字典的值。我以前的字典是:
{100000: (400, 'Does not want to build a %SnowMan %StopAsking', ['SnowMan', 'StopAsking'], [100, 200, 300], [400, 500]),
100001: (200, 'Make the ocean great again.', [''], [], [400]),
100002: (500, "Help I'm being held captive by a beast! %OhNoes", ['OhNoes'], [400], [100, 200, 300]),
100003: (500, "Actually nm. This isn't so bad lolz :P %StockholmeSyndrome", ['StockholmeSyndrome'], [400, 100], []),
100004: (300, 'If some random dude offers to %ShowYouTheWorld do yourself a favour and %JustSayNo.', ['ShowYouTheWorld', 'JustSayNo'], [500, 200], [400]),
100005: (400, 'LOLZ BELLE. %StockholmeSyndrome %SnowMan', ['StockholmeSyndrome', 'SnowMan'], [], [200, 300, 100, 500])}
这个字典的形式是 {key: (id, string, tags, likes, dislikes)} 我需要创建一个字典,它的键是第一个字典中的标签,它的值是包含标签,以字典的形式呈现。
例如,如果我们使用 tag 'SnowMan',新字典应该是这样的:
{'SnowMan': {400: ['Does not want to build a %SnowMan %StopAsking', 'LOLZ BELLE. %StockholmeSyndrome %SnowMan']}}
或者,如果我们使用 tag 'StockholmeSyndrome',新字典应该是这样的:
{'StockholmeSyndrome': {
500: ["Actually nm. This isn't so bad lolz :P %StockholmeSyndrome"],
400: ['LOLZ BELLE. %StockholmeSyndrome %SnowMan']}}
最后,新字典需要将之前字典中的所有标签都包含为键,包括没有标签的事件。
我真的被困在这个问题上,有人可以提供一些指导吗?
冉冉说
繁星淼淼
海绵宝宝撒
相关分类