从solr查询的结果中删除标头

时间:2019-03-19 08:29:34

标签: python json python-3.x solr

我的代码如下

username = 'user'
password = 'user'
url = 'http://di4301sw:8081/solr/metadone/select?fl=file.contenu&q=patient.ipp:3456&rows=14'
r = requests.get(url, auth=(username, password)) 
data = r.json()
with open('data.json', 'w') as f:
    json.dump(data, f)

我的结果看起来像这样

{"responseHeader": {"status": 0, "QTime": 0, "params": {"q": "patient.ipp:3456", "fl": "file.contenu", "rows": "14"}}, "response": {"numFound": 14, "start": 0, "docs": [{"file.contenu": "Biochimie d'urgence Dr F. Beyerle, Dr L. Chardon, A. Varennes Tel Secr\u00e9tariat

我希望结果从“ file.contenu”开始,即我不希望标题 谢谢您的期待

1 个答案:

答案 0 :(得分:1)

您应该解析响应以获得所需的结果:

data_to_dump=data['response']['docs'][0]

希望这会有所帮助