From 8c503bd4f393976546b4eb567417b7b9aff36b1f Mon Sep 17 00:00:00 2001 From: Melo Zhang <86137761+Melo3000@users.noreply.github.com> Date: Wed, 23 Apr 2025 11:51:51 +0800 Subject: [PATCH] =?UTF-8?q?Update=2022.=E5=AF=B9=E8=B1=A1=E7=9A=84?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96=E5=92=8C=E5=8F=8D=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8C=96.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改因 网站天行数据返回json格式更新 所导致的调用API产生的KeyError问题 --- ...\222\214\345\217\215\345\272\217\345\210\227\345\214\226.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/Day21-30/22.\345\257\271\350\261\241\347\232\204\345\272\217\345\210\227\345\214\226\345\222\214\345\217\215\345\272\217\345\210\227\345\214\226.md" "b/Day21-30/22.\345\257\271\350\261\241\347\232\204\345\272\217\345\210\227\345\214\226\345\222\214\345\217\215\345\272\217\345\210\227\345\214\226.md" index 39658ec7b..bda194084 100755 --- "a/Day21-30/22.\345\257\271\350\261\241\347\232\204\345\272\217\345\210\227\345\214\226\345\222\214\345\217\215\345\272\217\345\210\227\345\214\226.md" +++ "b/Day21-30/22.\345\257\271\350\261\241\347\232\204\345\272\217\345\210\227\345\214\226\345\222\214\345\217\215\345\272\217\345\210\227\345\214\226.md" @@ -221,7 +221,7 @@ import requests resp = requests.get('http://api.tianapi.com/guonei/?key=APIKey&num=10') if resp.status_code == 200: data_model = resp.json() - for news in data_model['newslist']: + for news in data_model['result']['newslist']: print(news['title']) print(news['url']) print('-' * 60)