【发布时间】:2020-11-01 13:55:14
【问题描述】:
在用 python 编写的字典和外部 json 文件上面临 json 解码错误。
import json
x = '{ "name:"John", "age":30, "city":"New york"}'
y = json.loads(x)
print(y ["age"])
json.decoder.JSONDecodeError: Expecting ':' delimiter: line 1 column 10 (char 9)
【问题讨论】:
-
:应该在 " 符号(名称键)之后
-
仔细看看输入字符串的第 9 个字符:这个引号应该在那里吗?
标签: python json dictionary