[英]unpaired low surrogate in loading json in python
I encounter a problem in loading a json file in python. 我在python中加载json文件时遇到问题。 My code looks like:
我的代码如下:
with open(file,'r') as infile:
json.load(infile)
I have 10 files which should be in the same format. 我有10个文件,应该采用相同的格式。 For 9/10 JSON files it works, but for one file it shows the error as follows:
对于9/10 JSON文件,它可以工作,但对于一个文件,它显示错误,如下所示:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/json/__init__.py", line 290, in load
**kw)
File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 365, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 381, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Unpaired low surrogate: line 1 column 27948557 (char 27948556)
How could I fix this problem? 我该如何解决这个问题?
尝试将simplejson升级到3.6.5并执行simplejson.load(infile)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.