我目前使用github3.py版本0.9.6,並且在調用時收到錯誤github3.organization(login) function :github3 0.9.6 TypeError:pop()至多需要1個參數(給出2個)
Traceback (most recent call last):
File "Main.py", line 23, in <module>
__main__()
File "Main.py", line 19, in __main__
Stats.git_auth(username, password, access_token)
File "/Users/edigiovine/Repositories/GitMetrics/Stats.py", line 36, in git_auth
git_orgs(gh)
File "/Users/edigiovine/Repositories/GitMetrics/Stats.py", line 49, in git_orgs
org = gh.organization(rel_org)
File "/Library/Python/2.7/site-packages/github3/github.py", line 971, in organization
return Organization(json, self) if json else None
File "/Library/Python/2.7/site-packages/github3/orgs.py", line 236, in __init__
super(Organization, self).__init__(org, session)
File "/Library/Python/2.7/site-packages/github3/models.py", line 311, in __init__
super(BaseAccount, self).__init__(acct, session)
File "/Library/Python/2.7/site-packages/github3/models.py", line 77, in __init__
super(GitHubCore, self).__init__(json)
File "/Library/Python/2.7/site-packages/github3/models.py", line 30, in __init__
self.etag = json.pop('ETag', None)
TypeError: pop() takes at most 1 argument (2 given)
我希望我能得到一些解決此問題的幫助。具體來說,我很好奇上次調用中None來自哪裏。
感謝您提前提供任何幫助!
EDIT1:我試圖調用基於用戶,這在我的情況比組織總榜單小得多提供的現有機構單位的名單上特定的組織,所以遍歷所有組織不會成爲一個在這種情況下對我有利(如果沒有給出列表,這恰好是我的默認情況)。
再次感謝!
EDIT2:我實現,顯然微不足道(不能給私人信息)的代碼示例:
# Defined username, password, access_token, and api_call_base in a
# config file, use them here to build the github object.
gh = github3.login(username, password, access_token, api_call_base)
# predefined_orgs_list is a list of the names of the organizations
# that are in focus for my project.
for needed_org in predefined_orgs_list:
# This is the function that throws the error I am receiving.
org = gh.organization(needed_org)
# If above function works, then the following value should be
# the same as in the predefined_orgs_list
print org.login
EDIT3:我知道gh.organization功能是什麼原因造成的問題在我的代碼中,正如堆棧跟蹤所見。我的問題是關於github3的庫,並詢問我如何解決/修復models.py中的pop()函數,這是拋出錯誤的函數。
EDIT4:我解決了這個問題,這要歸功於PDB: 從遍歷代碼,我發現,URL生成是動態的基礎上給予組織功能的輸入。
具體而言,我所擁有的是我們組織的默認基本網址,能夠正確收集我們的組織數據。我需要做的是修改我的代碼,使用兩個不同的URL,基於給出組織列表的條件與抓住所有組織。
現在已解決此問題。感謝大家!
你能提供一個代碼嗎? – soundslikeodd
給予一行代碼和回溯將無濟於事。什麼是「登錄」? – Leb
看起來像是在預計字典中出現一個列表。 – user2357112