import requests
url = "http://store.place.com.br/api/oms/pvt/orders"
headers = {
'accept': "application/json",
'content-type': "application/json",
'x-vtex-api-apptoken': "{{VTEX-API-TOKEN}}",
'x-vtex-api-appkey': "{{VTEX-API-KEY}}"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
url = "http://store.place.com.br/api/oms/pvt/orders/oderId"
headers = {
'accept': "application/json",
'content-type': "application/json",
'x-vtex-api-apptoken': "{{VTEX-API-TOKEN}}",
'x-vtex-api-appkey': "{{VTEX-API-KEY}}"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
我的结果是:
{" list":[{" orderId":" BWW-Lojas_Americanas-265033423001",... {"订单ID":" BWW-Lojas_Americanas-265032819901""序列":" 506927""市场
如何在多行中拆分每个列表?之后,我想将它们保存在不同的files.txt
中答案 0 :(得分:0)
您应该使用JSON
将回复读作requests.request(...).json()
。然后,您可以处理列表中的每个订单。
以下是一个例子:
response = requests.request("GET", url, headers=headers).json()
for order in response['list']:
# Process each order
# ...