简体   繁体   English

for循环中有很多带有数据JSONS的变量

[英]A lot of variables with data JSONS in for-loop

I try create for-loop to read data from json.我尝试创建 for 循环以从 json 读取数据。 But My code does not work.但我的代码不起作用。 Please tell me how can i travel to right way.请告诉我如何才能以正确的方式旅行。

with requests.Session() as session:
        session.headers.update(headers)

        response = session.get('https://api.allegro.pl/order/checkout-forms?limit=100')
        responsee = session.get('https://api.allegro.pl/order/checkout-forms?limit=100&offset=100')
        responseee = session.get('https://api.allegro.pl/order/checkout-forms?limit=100&offset=200')
        responseee3 = session.get('https://api.allegro.pl/order/checkout-forms?limit=100&offset=300')
        responseee4 = session.get('https://api.allegro.pl/order/checkout-forms?limit=100&offset=400')
        responseee5 = session.get('https://api.allegro.pl/order/checkout-forms?limit=100&offset=500')


        
        wyswietl =response.json()
        wyswietl2 = responsee.json()
        wyswietl3 = responseee.json()
        wyswietl4 = responseee3.json()
        wyswietl5 = responseee4.json()
        wyswietl6 = responseee5.json()
        
        for p in wyswietl['checkoutForms'],wyswietl2['checkoutForms'],wyswietl3['checkoutForms'],wyswietl4['checkoutForms'],wyswietl5['checkoutForms'],wyswietl6['checkoutForms']:
...
info = ['https://api.allegro.pl/order/checkout-forms?limit=100','https://api.allegro.pl/order/checkout-forms?limit=100&offset=100','https://api.allegro.pl/order/checkout-forms?limit=100&offset=200','https://api.allegro.pl/order/checkout-forms?limit=100&offset=300','https://api.allegro.pl/order/checkout-forms?limit=100&offset=400','https://api.allegro.pl/order/checkout-forms?limit=100&offset=500']
        for i in info:
            response = session.get(i)
            wyswietl = response.json()
        
            for p in wyswietl['checkoutForms']: ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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