Home > other >  AttributeError: 'NoneType' object has no attribute 'startswith'
AttributeError: 'NoneType' object has no attribute 'startswith'

Time:09-17

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

# execution API call and store the object
Url="https://api.github.com/search/repositories? Q=language: Python& Sort=star '
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']
# print (" Rsepositories returned: ", len (repo_dicts))

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 ")

An error as follows, a great god answer:
C: \ Users \ mi \ AppData \ Local \ designed \ Python \ Python38-32 \ Python exe C:/python_work data_download/python_repos py
The Status code: 200
Total repositories: 5893154
Traceback (the most recent call last) :
File "C:/python_work data_download/python_repos py", 31, the line in & lt; module>
Chart. Render_to_file (" python_repos. SVG ")
File "C: \ Users \ mi \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ pygal \ graph \ public py", line 114, in render_to_file
F.w rite (self. Render (is_unicode=True, * * kwargs))
File "C: \ Users \ mi \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ pygal \ graph \ public py", line 52, render in
The self. The setup (* * kwargs)
File "C: \ Users \ mi \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ pygal \ graph \ base py", line 218, setup in
Self. SVG. Pre_render ()
File "C: \ Users \ mi \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ pygal \ SVG py", line 428, in pre_render
Self. Add_styles ()
File "C: \ Users \ mi \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ pygal \ SVG py", line 92, in add_styles
Colors=self. Graph. Style. Get_colors (self. The id, the self. Graph. _order)
File "C: \ Users \ mi \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ pygal \ style py", line 162, in get_colors
Value_colors. Append (' white 'if is_foreground_light (
File "C: \ Users \ mi \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ pygal \ colors py", line 158, in is_foreground_light
Return rgb_to_hsl (* parse_color (color) [3] : [2] <17.9
File "C: \ Users \ mi \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ pygal \ colors py", line 96, in parse_color
If color. Startswith (' # ') :
AttributeError: 'NoneType' object has no attribute 'startswith'

Process finished with exit code 1
  • Related