我想知道我应该调用哪个方法(以及在哪个对象上)以及如何调用该方法(必需参数及其含义)。
最佳答案
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)
If you are using token then you should have at least repo scope of your token to do it. https://developer.github.com/v3/oauth/#scopes
参见: https://developer.github.com/v3/repos/contents/和 https://github.com/PyGithub/PyGithub
关于python - 如何使用 PyGithub 更新文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40630829/