TypeError: das JSON-Objekt sein muss, str, nicht die 'Antwort' mit Python 3.4

Ich bin immer diese Fehlermeldung und ich kann nicht herausfinden, was das problem ist:

Traceback (most recent call last):
  File "C:/Python34/Scripts/ddg.py", line 8, in <module>
    data = json.loads(r)
  File "C:\Python34\lib\json\__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'Response'

Das ist mein code:

import requests, json

search_q = input('Enter query: ')

r = requests.get('https://api.duckduckgo.com/?q=%s&format=json&pretty=1' % search_q)

if r.status_code == requests.codes.ok:
    data = json.loads(r)
    node = data['RelatedTopics']['Result']
    print (str(node))
else:
    bad_r.raise_for_status()
InformationsquelleAutor Y7da | 2016-02-09
Schreibe einen Kommentar