Update 22.对象的序列化和反序列化.md
修改因 网站天行数据返回json格式更新 所导致的调用API产生的KeyError问题
This commit is contained in:
parent
7a798e481d
commit
8c503bd4f3
|
|
@ -221,7 +221,7 @@ import requests
|
||||||
resp = requests.get('http://api.tianapi.com/guonei/?key=APIKey&num=10')
|
resp = requests.get('http://api.tianapi.com/guonei/?key=APIKey&num=10')
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
data_model = resp.json()
|
data_model = resp.json()
|
||||||
for news in data_model['newslist']:
|
for news in data_model['result']['newslist']:
|
||||||
print(news['title'])
|
print(news['title'])
|
||||||
print(news['url'])
|
print(news['url'])
|
||||||
print('-' * 60)
|
print('-' * 60)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue