Answer the question
In order to leave comments, you need to log in
How to read a list in a file with a given segment?
Goodnight.
I take the product id from the file and insert it into the request url. The problem is that there are too many product id in the file (more than 100000), how can I read the file to insert the first 400 id into the request, then the next 400 and so on until the end file?
def get_product_data():
payload = {
'product_ids': ''.join(
[line.strip() for line in open('id.json', 'r')]
)
}
f = requests.get('https://example.com./v2/product/getDetails?', params=payload)
d = f.json()
return d
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question