0
我成功地从JSON中提取响应。然而,我无法列出所有或提取什么,我需要的关键及其对提取JSON值时获取错误“KeyError”
下面是我的代码:
import requests
response = requests.get("https://www.woolworths.com.au/apis/ui/Product/Specials/half-price?GroupID=948&isMobile=false&pageNumber=1&pageSize=36&richRelevanceId=SP_948&sortType=Personalised")
data = response.json()
我试图做data['Stockcode']
,但没有运气还是我用data['Product']
它说:
>>> data['Product']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'Product'
>>> data['Products']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'Products'