Nooby面临的KeyError问题

时间:2018-10-02 18:33:28

标签: json

# Make list to collect order UIDs
order_uids = []

for index, row in coordinates.iterrows():
    # Build request URL
    requestURL = url + row['product'] + "/subsetOrder?latitude=" + str(row['latitude']) + "&longitude=" + str(row['longitude']) + "&email=" + row['email'] + "&uid=" + row['site_id'] + "&startDate=" + row['start_MODIS_date'] + "&endDate=" + row['end_MODIS_date'] + "&kmAboveBelow=" + str(row['kmAboveBelow']) + "&kmLeftRight=" + str(row['kmLeftRight'])
# Submit request
response = requests.get(requestURL, headers=header)

# Append UID to list
order_uids.append(json.loads(response.text)['order_id'])

print(order_uids)

为什么会出现此错误

KeyError                                  Traceback (most recent call last)
<ipython-input-4-d66059bfd6b6> in <module>()
     10 
     11     # Append UID to list
---> 12     order_uids.append(json.loads(response.text)['order_id'])
     13 
     14 print(order_uids)

KeyError: 'order_id'

0 个答案:

没有答案