Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python json.decoder.JSONDecodeError:预期值:第1行第1列(字符0)(SCRAPY Shell)_Python_Json_Scrapy - Fatal编程技术网

Python json.decoder.JSONDecodeError:预期值:第1行第1列(字符0)(SCRAPY Shell)

Python json.decoder.JSONDecodeError:预期值:第1行第1列(字符0)(SCRAPY Shell),python,json,scrapy,Python,Json,Scrapy,我用一个粘壳运行了这个程序。我试图打印JSON响应,但它给了我一个错误: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 怎么解决呢?感谢你的回答 scrapy shell https://directory-service-dot-gweb-edu-activity-app.appspot.com/directory/search?expertTypes=trainer&query=

我用一个
粘壳
运行了这个程序。我试图打印
JSON
响应,但它给了我一个错误:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
怎么解决呢?感谢你的回答

   scrapy shell https://directory-service-dot-gweb-edu-activity-app.appspot.com/directory/search?expertTypes=trainer&query=&userPosition=31.170406299999996,%2072.7097161
    
    >>> import json
    >>> print(json.loads(response.body))

文件的开头如下所示:

)]},
{“合伙人”:[],
...
这不是有效的JSON。除了向网站的开发人员报告这一点之外,我唯一能找到的解决方法就是在开始时切掉部分

print(json.loads(response.body[6:]))
试试这个:

import json
jd = json.dumps(response.text)
print(json.loads(jd))