如何使用PyGithub更新文件?

阿比舍克·库马尔(Abhishek kumar)

我想知道我应该调用哪个方法(和其对象),以及如何调用该方法(需要的参数和它们的含义)。

谢尔盖·卢奇科(Sergey Luchko)
import github

g = github.Github(token)
# or  g = github.Github(login, password)

repo = g.get_user().get_repo("repo_name")
file = repo.get_file_contents("/your_file.txt")

# update
repo.update_file("/your_file.txt", "your_commit_message", "your_new_file_content", file.sha)

如果您使用的令牌,那么你至少应该有回购您的令牌的范围内做到这一点。https://developer.github.com/v3/oauth/#scopes

参见: https : //developer.github.com/v3/repos/contents/https://github.com/PyGithub/PyGithub

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章