Home > database >  Using the python primer visual data for help
Using the python primer visual data for help

Time:03-31

 
The import requests
The import pygal
The from pygal. Style import LightColorizedStyle as the LCS, LightStyle as LS

# execution API call and store the response
Url="https://api.github.com/search/repositories? Q=language: python& Sort=stars'
R=requests. Get (url)
Print (" Status code: ", r.s tatus_code)

# the API response is stored in a variable
Response_dict=r.j son ()
Print (" Total repositories: ", response_dict [' total_count '])

# to explore information about warehouse
Repo_dicts=response_dict [' items']

Names, stars=[], []
For repo_dict repo_dicts in:
Names. Append (repo_dict [' name '])
Stars. Append (repo_dict [' stargazers_count '])

# visualization
My_style=LS (' # 333366, base_style=LCS)
Chart=pygal. Bar (style=my_style, x_label_rotation=45, show_legend=False)
Chart. The title='Most - Starred Python Projects on making'
Chart. X_labels=names

Chart. The add (' ', stars)
Chart. Render_to_file (' Python_repos. SVG)


Results why this kind of wrong, I have are made in accordance with the book, pygal also installed
Line 23, in & lt; module>
My_style=LS (' # 333366, base_style=LCS)
TypeError: __init__ () takes a positional argument but 2 were given
  • Related