问题描述
- python json解析出现No JSON object could be decoded的报错
- 源代码:#coding:utf-8
import requests
import re
import jsonurl=""http://www.newrank.cn/public/info/list.js?t=1461063208.68""
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent }
jscontent=requests.get(""http://www.newrank.cn/public/info/list.js?t=1461063208.68""headers=headers).content
jsdict=json.loads(jscontent)错误信息:Traceback (most recent call last):
File ""D:/Python/JetBrains PyCharm 5.0.4/PyCharm 5.0.4/Myproject/test1/test2.py"" line 10 in
jsdict=json.loads(jscontent)
File ""D:Pythonlibjson__init__.py"" line 339 in loads
return _default_decoder.decode(s)
File ""D:Pythonlibjsondecoder.py"" line 364 in decode
obj end = self.raw_decode(s idx=_w(s 0).end())
File ""D:Pythonlibjsondecoder.py"" line 382 in raw_decode
raise ValueError(""No JSON object could be decoded"")
ValueError: No JSON object could be decoded是因为json的bom头问题吗,我也尝试过一些网上的去除bom头的办法,不过都不管用,还望指点,非常头疼,谢谢!
解决方案
Could not write JSON: java.lang.Integer cannot be cast to java.math.BigInteger
使用Number解决
......
答案就在这里:Could not write JSON: java.lang.Integer cannot be cast to java.math.BigInteger
解决方案二:
你得到的content先看看是什么数据 看上去不是json数据