[ { "id": 1, "juzi": "熟悉的地方没有风景", "from": "网络", "from_who": null, } ]
我想把这样的字符串转换成字典
发现 python无法处理null这样的字符串
解决方案
null = "" a = """[ { "id": 1, "juzi": "熟悉的地方没有风景", "from": "网络", "from_who": null, } ]""" a = eval(a) print(a)
[{'id': 1, 'juzi': '熟悉的地方没有风景', 'from': '网络', 'from_who': ''}] Process finished with exit code 0
只要在前面添加一句
null = ""
Comments NOTHING