for repo in g.get_user().get_repos():
print (repo.full_name)
json_pulls = requests.get('https://api.github.com/repos/' + repo.full_name + '/pulls?state=open+updated=<' + str(cutoff_date.date())+ '&sort=created&order=asc')
if (json_pulls.ok):
for item in json_pulls.json():
for c in item.items():
#print(c["0"]["title"])
#print (json.dumps(state))
print(c)
기존의 repos를 통해
코드주기와는 풀 요청을 나열하고 나는 출력을 얻을 :
을하지만, 난 내 인생에 대한 폐기물 수집하는 방법을 알아낼 수 없습니다
print(c['0']['title'])
이 -a 관 오류가은 내가 무엇을 찾고 있어요 것은 인 오류를 정의되지 않은 -
print(c['title'])
: 내가 참조를 사용하여 시도 ... 개별 필드에서 t 각 요청에 대한 간단한 목록 ....title id state base/sha head/sha
캔 누군가가 내 파이썬 스크립트에서 json 항목을 참조 할 때 내가 미치고있는 것을 지적하고있다.
으로 전체 코드는 ... 물론 당신의 도움이 함께 :
# py -m pip install <module> to install the imported modules below. # # # Import stuff from github import Github from datetime import datetime, timedelta import requests import json import simplejson # # #declare stuff # set the past days to search in the range PAST = 5 # get the cut off date for the repos 10 days ago cutoff_date = datetime.now() - timedelta(days=PAST) #print (cutoff_date.date()) # Repo oauth key for my repo OAUTH_KEY = "(get from github personal keys)" # set base URL for API query BASE_URL = 'https://api.github.com/repos/' # # # BEGIN STUFF # First create a Github instance: g = Github(login_or_token=OAUTH_KEY, per_page=100) # get all repositories for my account that are open and updated in the last no. of days.... for repo in g.get_user().get_repos(): print (repo.full_name) json_pulls = requests.get('https://api.github.com/repos/' + repo.full_name + '/pulls?state=open+updated=<' + str(cutoff_date.date())+ '&sort=created&order=asc') if (json_pulls.ok): for item in json_pulls.json(): print(item['title'], item['id'], item['state'], item['base']['sha'], item['head']['sha'])
되찾기 사이트는 두 가지의 repos와 대결하는 1 명 또는 2 개의 풀 요청, 간단한 사이트입니다.
스크립트가 끝나면 모든 repos를 반복하고, x 일보다 오래되어서 열린 요청을 찾고, 분기에 대한 sha (그리고 master 브랜치는 sha, 추가하려면 ...., 가지를 마스터하지 않는 가지를 제거하여 예전의 코드를 제거하고 깔끔한 REPOS을 유지하기 위해 요청을 당겨) .....
for 루프 앞에 논리를 게시 할 수도 있습니까 (https://stackoverflow.com/help/mcve 참조). 그러면 잘라 내기를 복사하여 테스트 할 수 있습니까? –
스크린 샷을 덤프하십시오. 우리에게 예제 입력 행을 테스트 해보십시오. – tdelaney
'item [ "title"]'등 ... – tdelaney