Get json data via url and use in python (simplejson)

后端 未结 3 876
不思量自难忘°
不思量自难忘° 2021-01-30 02:38

I imagine this must have a simple answer, but I am struggling: I want to take a url (which outputs json) and get the data in a usable dictionary in python. I am stuck on the la

3条回答
  •  时光说笑
    2021-01-30 03:07

    Try

    f = opener.open(req)
    simplejson.load(f)
    

    without running f.read() first. When you run f.read(), the filehandle's contents are slurped so there is nothing left when your call simplejson.load(f)

提交回复
热议问题