我知道这种问题以前已经被问过,但我找不到解决我的问题的方法。
我的函数返回的是这种格式的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字典吗?
import json; json.loads(myver)
吗? - Felk... null, , "object_type": ...
。这个双逗号确实是无效的 JSON,但不清楚 OP 是否有意将其放在那里。 - Felk