我有JSON数据,需要格式化并将其发送到服务器,并将null值设置为null。 Python中的字典不能将null作为值,而可以将“ null”作为值。如何将以上内容转换为Python可以识别的字典?
a = {"name":"p_retailprice","type":"DOUBLE","comment":"","precision":null,"scale":null}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'null' is not defined
答案 0 :(得分:3)
Python中null关键字的等效项为None。
尝试
a = {"name":"p_retailprice","type":"DOUBLE","comment":"","precision":None,"scale":None}