小编Tai*_*Ali的帖子

给出错误"JSON对象必须是str,而不是'bytes'"

我正在关注如何使用带有python的弹性搜索的教程(link = https://tryolabs.com/blog/2015/02/17/python-elasticsearch-first-steps/#contacto)我遇到了这个错误.

import json
    r = requests.get('http://localhost:9200') 
    i = 1
    while r.status_code == 200:
        r = requests.get('http://swapi.co/api/people/'+ str(i))
        es.index(index='sw', doc_type='people', id=i, body=json.loads(r.content))
        i=i+1

    print(i)
Run Code Online (Sandbox Code Playgroud)

TypeError:JSON对象必须是str,而不是'bytes'

python json python-requests

4
推荐指数
1
解决办法
4015
查看次数

标签 统计

json ×1

python ×1

python-requests ×1