【发布时间】:2019-07-04 14:59:23
【问题描述】:
我练习编写一些代码以从 GitHub 获取 Python 的顶级存储库,这是我看到的错误:
这是导致上述错误的代码:
import requests
import pygal
from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS
path = 'https://api.github.com/search/repositories?q=language:python&sort=stars'
r = requests.get(path)
response_dict = r.json()
# Explore information about the repositories.
repo_dicts = response_dict['items']
names, plot_dicts = [], []
for repo_dict in repo_dicts:
names.append(repo_dict['name'])
plot_dict = {
'value': repo_dict['stargazers_count'],
'label': repo_dict['description'],
'xlink': repo_dict['html_url'],
}
plot_dicts.append(plot_dict)
my_style = LS('#333366', base_style=LCS)
# Make visualization.
my_config = pygal.Config()
chart = pygal.Bar(my_config, style=my_style)
my_style = LS('#333366', base_style=LCS)
chart.title = 'Most-Starred Python Projects on GitHub'
chart.x_labels = names
chart.add('', plot_dicts)
chart.render_to_file('python_repos.svg')
请你帮我解决这个问题。谢谢
【问题讨论】:
-
请使用代码格式进行回溯。它们在报价格式中非常难以阅读
-
我很抱歉,但我只是添加了一张跟踪簿的图片,所以要求我在代码格式化跟踪后提供更多信息
标签: python visualization pygal