我在Python中有一个特殊的列表:
peculiar_list=['"{\\n \\"persons\\": \\"person 1\\",\\n \\"score\\": \\"Very Good\\",\\n \\"comment\\": \\"This result was found to be very good for the the user\'s interest.\\",\\n \\"level\\": \\"high level\\"\\n}"',
'"{\\n \\"persons\\": \\"person 2\\",\\n \\"score\\": \\"Pretty Good\\",\\n \\"comment\\": \\"This result, coupled with other data, was found to be pretty good.\\",\\n \\"level\\": \\"high level\\"\\n}"']
我想摆脱\\n
,\\
,并最终返回一个干净的dict
对象允许
peculiar_list[0]['persons']
来显示“person 1”。是否有自动的方法来执行此操作?
1条答案
按热度按时间py49o6xq1#
您的列表包含已编码两次的JSON,因此调用
json.loads()
两次来解码它。