pygal制图“AttributeError: ‘NoneType’ object has no attribute ‘decode’《Python编程:从入门到实践》
最近在刷《Python编程:从入门到实践》一书 webAPI 部分使用github接口绘制柱状图
遇到此报错 通过核对书中代码 发现并无错误
pygal制图“AttributeError: 'NoneType' object has no attribute 'decode'
通过分析是 接口中 description
为空原因 ps 原来大神代码也有不健壮的时候啊
完整代码:
import requests
import pygal
from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS
# 执行api调用并储存响应
url = 'https://api.github.com/search/repositories?q=language:python&sort=stars'
r = requests.get(url)
print("Status code:", r.status_code)
# 将api响应储存在一个变量中
response_dict = r.json()
# 处理结果 打印字典的键
print('总数',