我有 JSON 数据,需要对其进行格式化并将空值设置为 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
Run Code Online (Sandbox Code Playgroud)
Python 中 null 关键字的等价物是 None。
尝试
a = {"name":"p_retailprice","type":"DOUBLE","comment":"","precision":None,"scale":None}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14323 次 |
最近记录: |