python运行报错【json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 13 (char 12)】是为什么

运行下面一串代码,然后就报错了
import json

json_str = '{"name":"张三", "age":"18"}'

json_dict = json.loads(json_str)
print(type(json_dict))

Traceback (most recent call last):
File "D:/python/test/实例练习/json库.py", line 14, in
json_dict = json.loads(json_str)
File "D:\Python38-32\lib\json_init_.py", line 357, in loads
return _default_decoder.decode(s)
File "D:\Python38-32\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\Python38-32\lib\json\decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 13 (char 12)

怎样能不报错呢

"张三"之后的逗号写成了中文全角的,要改成英文半角的。

img

你题目的解答代码如下:

import json

json_str = '{"name":"张三", "age":"18"}'  #这里逗号改成英文的即可

json_dict = json.loads(json_str)
print(type(json_dict))

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img