【发布时间】:2016-05-21 19:10:22
【问题描述】:
假设我有一系列字典形式的推文,结构如下:
Tweet = {
'created_at': 'Thu Apr 21 16:03:40 +0000 2016',
'text': 'Look at this dog!',
'entities': {'hashtags': ['dog'] },
'favorite_count': 0,
'user': {'screen_name': 'Jake_Jake'},
'retweet_count': 0
}
我想创建一个新字典,以便“hashtags”和“screen_name”键和值不再嵌套:
{'created_at': 'Thu Apr 21 16:03:40 +0000 2016', 'text': 'Look at this dog!', 'favorite_count': 0, 'hashtags': ['dog'], 'retweet_count': 0, 'screen_name': 'Jake_Jake'}
关于我如何做到这一点的任何建议?谢谢。
【问题讨论】:
标签: python list dictionary