在下面的代码中,
[{word: score_tweet(tweet) for word in tweet} for tweet in tweets]
我正在获取字典列表:
[{u'soad': 0.0, u'<3': 0.0}, {u'outros': 0.0, u'acredita': 0.0}]
我只想获得一个平面字典,例如:
{u'soad': 0.0, u'<3': 0.0, u'outros': 0.0, u'acredita': 0.0}
我应该如何更改我的代码? 注意:我使用的是 Python 2.7。
最佳答案
{word: score_tweet(tweet) for tweet in tweets for word in tweet}
关于python - 嵌套字典理解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16513255/