【发布时间】:2022-10-24 00:44:08
【问题描述】:
我想在 Python 中使用 PyGithub 附加到一个已经存在的 .txt 文件。 我试过这段代码:
git = Github(TOKEN)
repo = git.get_repo("Repository")
file = repo.get_contents("Textfile.txt", ref="Ref")
repo.update_file(file.path, "test", "Text I wanna store", file.sha, branch="Ref")
但此代码删除旧数据并仅存储此数据,即“我想存储的文本”。
我想将此数据存储在先前存储的数据的末尾,例如 “我要存储的以前的数据文本”
【问题讨论】:
-
下载文件,追加数据,上传新的...
-
我现在正在使用这种方式,但没有更好的方法来做到这一点。或者库中的任何内置函数可以做到这一点?
标签: python file github pygithub