python中的json注意事项
案例一、正常輸出情況
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
輸出錯誤
?
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的python中的json注意事项的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 类不能直接通过import得到
- 下一篇: websocket python爬虫_p