import requests
# #
def get_names():
names = input('請輸入要查詢的api名稱,以空格分隔:')
return names.split()
def check_repos(names):
repo_api = ''
ecosys_api = 'topic:'
for name in names:
repo_info = requests.get(repo_api + name).json()['items'][0]
stars = repo_info['stargazers_count']
forks = repo_info['forks_count']
total_count = requests.get(ecosys_api+name).json()['total_count']
print(name)
print("stars:" + str(stars))
print("forks:" + str(forks))
print('ecosys:' + str(total_count))
print('-'*20)
if __name__ == "__main__":
# names = ['django','flask','unittest']
names = get_names()
check_repos(names)
學會通過**提供的api獲取需要的資料
從 github 上選出符合這些條件的專案:
最近一周內發布的
語言是 python
size 小於200k的**
把這些專案的鏈結 print 出來。
# coding:utf-8
import requests
"""api形式 /code?q=language:python+size:<200+repo:目錄名
q引數:
language:指定語言
size:指定檔案大小,如size:<200表示檔案小於200kb
repo:指定目錄(必要引數)
示例: <200+repo:tensorflow/tensorflow
"""get_code_api = ""
get_repo_api = "language:python"
# 編寫函式,實現在github某一目錄下尋找code檔案的功能
def get_code(language, size, repo):
url = get_code_api + "language:" + language + "+size:" + size + "+repo:" + repo
# 訪問github介面
info = requests.get(url).json()
if 'items' in info:
for i in info['items']:
print(i['html_url'])
# 編寫函式,查詢更新時間在last_week之後的專案
def get_project(last_week):
# 訪問github介面
info = requests.get(get_repo_api).json()
for i in info['items']:
created_time = i['created_at']
if created_time > last_week:
language = "python"
size = "<200"
# 從info資料中獲取專案的目錄
repo = i['html_url'].replace("", "")
# 傳入三個限制條件,呼叫查詢code檔案的函式
get_code(language, size, repo)
# 呼叫查詢專案的函式,設定上個星期的時間
get_project("2019-05-19t00:00:00z")
資料庫結構的快速對比和同步
企業業務系統開發過程中,會維護實際業務執行的生產庫和開發庫,由於很多企業的業務的流程變化時頻繁的,所以,開發人員在開發庫中會頻繁的增減表 表字段 檢視 儲存過程等,如何方便的比較生產庫和開發庫之間結構的變化是乙個非常繁瑣的工作。現在介紹一款軟體可以方便的幫助大家完成這個繁瑣的工作。資料庫資料對比工具...
st的各種庫對比
目前已知st的庫有四種,分別是 1 stm32snippets 2 standard peripheral library 3 stm32cube hal 4 stm32cube ll 一 stm32snippets為高度優化的暫存器操作的集合。占用記憶體小,適合喜歡底層開發的人員使用,目前只有st...
Linux 統計多個檔案中的總行數值
思路 首先統計出每個檔案的行數,然後將數值數值寫入臨時檔案中 然後迴圈多個檔案,追加數值至臨時檔案,最後對臨時檔案裡每行的數值進行彙總 bin bash 置0echo log.log ls cib dm shell sql while read file name do 迴圈追加每個文字的行數至lo...