我正在用Spark创建一个bot(企业聊天),在Python中,我使用PyGitHub作为图书馆。 因此,当我在机器人的房间里写入“回购”时,他必须将我的回购清单寄回给我。 它适用于我的github个人帐户,但不适合我的专业帐户。 如果你能解释我为什么? 这里我的代码:PyGithub,无法从企业获得回购
def gitTest(self, details, message):
url = "https://enter-prise.com"
token = "abcd"
github = Github(token, base_url=url)
for repo in github.get_organization("org").get_repos():
self.answer(details.roomId, markdown=repo.name)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/mflamant/Documents/bot/CiscoSparkPython/testbotforgithub/main.py", line 44, in Main
bot.isRunnable()
File "/home/mflamant/Documents/bot/CiscoSparkPython/testbotforgithub/utils/Compute.py", line 47, in isRunnable
self.spark(message[0], message[1])
File "/home/mflamant/Documents/bot/CiscoSparkPython/testbotforgithub/testbotforgithub.py", line 33, in spark
return self.answer(details.roomId, markdown=self.gitTest(details, message))
File "/home/mflamant/Documents/bot/CiscoSparkPython/testbotforgithub/testbotforgithub.py", line 56, in gitTest
for repo in github.get_organization(adt).get_repos():
File "/usr/local/lib/python2.7/dist-packages/PyGithub-1.35-py2.7.egg/github/Organization.py", line 539, in get_repos
self.url + "/repos",
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
你能解释我什么是错我的代码?谢谢
'self.url'显然是'None'。 –
是的,但我不明白它是什么意思,以及如何改变它? – Kravennagen
这意味着你正试图添加两件你不能有意义地加在一起的东西。回想小学数学课。你会告诉老师他/她是否要求你添加5号椅子?你可能会说这个问题没有道理,你会是对的。 Python告诉你'self.url'是'None',它不存在,不存在,并且你要求它相当于将5添加到椅子上。你需要创建它。请参阅@ wpercy的答案。 –