【发布时间】:2017-08-17 15:43:10
【问题描述】:
我知道以前有人问过这类问题,但我无法找到解决问题的方法
我的函数以这种格式返回 unicode
{"set_id": "Rome", "group": "human", "attachments": null, , "object_type": "Prop", "attached": null, "tag_id": "prop", "Double Click": "reference", "files": "/makeup/Data/weapons/rifle", "source": "cupid", "attachment_label": null, "require_attachment": true, "rate": "high", "location": "/set2/ep1/Objects/weapons/machineguns/gun.txt", "attachment_type": null, "icon_path": "/resource/asset_manager/icons/rifle.bmp"}
检查类型时显示它是<type 'unicode'>
我尝试了ast.literal_eval(myver),但没有运气
还有哪些其他方法可以将其转换为 python 字典?
【问题讨论】:
-
对我来说这看起来像JSON-String。你试过
import json; json.loads(myver)吗? -
@Felk 这是无效的 JSON。
-
该示例包含此位:
... null, , "object_type": ...。双逗号确实是无效的 JSON,但不清楚 OP 是否意味着存在
标签: python dictionary unicode