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'