خلاصه کردن مخزنهای برتر
اگر بخواهیم این دادهها را بصری کنیم به دادههای بیش از یک مخزن نیاز داریم. بیایید حلقهای بنویسیم تا اطّلاعات منتخب دربارهی هر مخزن را چاپ کند تا بتوانیم آنها را در بصریسازی خود بیاوریم:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
--snip--
# Explore information about the repositories.
repo_dicts = response_dict['items']
print(f"Repositories returned: {len(repo_dicts)}")
print("\nSelected information about each repository:")
for repo_dict in repo_dicts: # ②
print(f"\nName: {repo_dict['name']}")
print(f"Owner: {repo_dict['owner']['login']}")
print(f"Stars: {repo_dict['stargazers_count']}")
print(f"Repository: {repo_dict['html_url']}")
print(f"Description: {repo_dict['description']}")
|
پیام معرّفی را چاپ میکنیم. داخل دیکشنریهای repo_dicts حلقه میزنیم. داخل حلقه نام هر پروژه، مالک آن، تعداد ستارهها، URL و شرح پروژه را چاپ میکنیم، مانند زیر:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
Status code: 200
Total repositories: 3494040
Repositories returned: 30
Selected information about each repository:
Name: awesome-python
Owner: vinta
Stars: 61549
Repository: https://github.com/vinta/awesome-python
Description: A curated list of awesome Python frameworks, libraries, software
and resources
Name: system-design-primer
Owner: donnemartin
Stars: 57256
Repository: https://github.com/donnemartin/system-design-primer
Description: Learn how to design large-scale systems. Prep for the system
design interview. Includes Anki flashcards.
--snip--
Name: python-patterns
Owner: faif
Stars: 19058
Repository: https://github.com/faif/python-patterns
Description: A collection of design patterns/idioms in Python
|