本文共 656 字,大约阅读时间需要 2 分钟。
案例一、正常输出情况
import json
jsonData = '{"a":1,"b":2,"c":1.2,"d":true,"e":null,"e":null}';
text = json.loads(jsonData)
text
输出
{'a': 1, 'b': 2, 'c': 1.2, 'd': True, 'e': None, 'f': None}
案例二、json中的引号变成单引号
File "<ipython-input-71-9db4caf88c5e>", line 3
jsonData = '{"a":1,"b":2,"c":1.2,"d":true,"e":null,'f':null}'; ^ SyntaxError: f-string: single '}' is not allowed
案例三、布尔值变成大写开头会怎么样呢,即python中的规范
import json
jsonData = '{"a":1,"b":2,"c":1.2,"d":True,"e":null,"f":null}';
text = json.loads(jsonData)
text
输出错误
案例四、null中替换成None,可不可以呢,python中对None的定义
import json
jsonData = '{"a":1,"b":2,"c":1.2,"d":true,"e":None,"f":null}';
text = json.loads(jsonData)
text
输出错误
转载地址:http://cerm.baihongyu.com/