2016-11-16 5 views
3

私はどのメソッドを呼び出すべきか(そしてどのオブジェクトで)、どのメソッドを呼び出すべきか(必要なパラメータとその意味)を知りたい。PyGithubを使ってファイルを更新するには?

ありがとうございます!

+0

2箇所:https://developer.github.com/v3/repos/contents/とhttps://github.com/PyGithub/ PyGithub/blob/master/github/InputFileContent.py –

答えて

3
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

+0

PyGithub docsにはこれに関するリファレンスがありませんので、ありがとう! –

関連する問題