我希望有人能帮我解决这个问题。我有一个看起来像这样的字符串 a = '[{"name": "bob", "age":"11", "participantid":"Me", "sentiment":"NEUTRAL", "content":"Hey, how you doing."}, {{"name": "Roland", "age":"16", "participantid":"boy", "sentiment":"NEUTRAL", "content":"Hey, I'm doing good and you?."}]'我的目标是返回列表而不是字符串,所以我期待这样的事情: a = [{"name": "bob", "age":"11", "participantid":"Me", "sentiment":"NEUTRAL", "content":"Hey, how you doing."}, {{"name": "Roland", "age":"16", "participantid":"boy", "sentiment":"NEUTRAL", "content":"Hey, I'm doing good and you?."}]我已经坚持了一段时间,我使用了替换和剥离,但没有任何效果。谢谢你的帮助。
1 回答
繁星淼淼
TA贡献1775条经验 获得超11个赞
试试这个:
import json
print(json.loads(a))
或这个:
import ast
print(ast.literal_eval(a))
添加回答
举报
0/150
提交
取消