如何使用 PyGithub 在组织中创建新存储库

Bar*_*ith 1 python api github github-api pygithub

如何在 Github 上使用 PyGithub 在组织中创建新存储库?我特别想知道如何使用该create_repo方法?

我的问题与这个问题相同,但我希望创建的存储库出现在组织中。

在没有组织级别的情况下创建存储库的解决方案是:

g = Github("username", "password")
user = g.get_user()
repo = user.create_repo(full_name)
Run Code Online (Sandbox Code Playgroud)

Bar*_*ith 7

这个链接给了我答案:链接

我想我应该更新我的问题,让其他人知道解决方案是什么。

很简单:

from github import Github

# using username and password
g = Github("Username", "Password")
org = g.get_organization('orgName')

repo = org.create_repo("test name")
Run Code Online (Sandbox Code Playgroud)