json.loads()报错处理

# coding=utf-8

import json, re

a = '''{"bulletAttributes":["A-line silhouette with a relaxed fit.","High waisted.","Hits at the upper calf.","Model is 5'9" (176 cm), size S, wearing a regular Gap size 4."]}'''
print(json.loads(a))
print(re.sub(r'''\d+'\d+"''', '', a))
'''
报错:json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 119 (char 118)

'''
会提示第几行第几个字符报错, 可以把报错的字符修复下

比如:
15'9" 无用, re.sub(r'''\d+'\d+"''', '', a)

print(json.loads(re.sub(r'''\d+'\d+"''', '', a)))
posted @ 2019-08-29 11:57  殇夜00  阅读(51)  评论(0)    收藏  举报