使用python将json中的字符串组合为单个字符串

2024-09-30 16:34:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个json,如下所示:

{'body_text': [u'The',u'in Wynnewood, OK, just south of Oklahoma City,\xa0is h',u'eral different exotic animals:']}

如何获得输出:

{'body_text': [u'The in Wynnewood, OK, just south of Oklahoma City,\xa0is heral different exotic animals:']}

Tags: ofthetextincitybodyokjust
1条回答
网友
1楼 · 发布于 2024-09-30 16:34:51

您可以使用^{}。这允许连接字符串列表,并在其中插入另一个字符串:

d = {'body_text': [u'The',u'in Wynnewood, OK, just south of Oklahoma City,\xa0is h',u'eral different exotic animals:']}

d['body_text'] = ' '.join(d['body_text'])
print d

输出

{'body_text': 'The in Wynnewood, OK, just south of Oklahoma City,\xa0is h eral different exotic animals:'}

相关问题 更多 >