简体   繁体   中英

Http Response Python

like the response.json() does not display anything but on the other hand the response.text displays the results how to loop through response.text Exemple de mon code

def api:
  url = 'http://api-content/product/GetProduct'
  x = requests.get(url)
  content=x.text

"produits":[{
    "des":"blaa",
     "cont":"sdf"
 }]

Merci de votre aide

I always do json.loads(x.text) and that seems to work for me

def api:
  url = 'http://api-content/product/GetProduct'
  x = requests.get(url)
  import json
  r = json.loads(x.text)
  for i in r:
      print(i)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM