Python Github 更新文件抛出 UnknownObjectException (404)

问题描述

我正在尝试使用以下代码更新 github 上文件内容

file = repo.get_contents('test.csv',ref="main")
data = file.decoded_content.decode("utf-8")
data += "\n test;test;test"
repo.update_file(file.path,"automatic update",data,file.sha,branch='main')

最后一行返回一个神秘的错误堆栈:github.GithubException.UnkNownObjectException: 404 {"message": "Not Found","documentation_url": "https://docs.github.com/rest/reference/repos#create-or-update-file-contents"}

get 方法似乎有效,因为它允许我打印出文件的原始内容。任何指针,为什么 update_file 方法不起作用?

TIA!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)