我正在尝试使用pygithub库来编辑已经创建的gist,但是到目前为止我还没有做到这一点。
import github.InputFileContent
from github import Github
g = Github("priv key")
gist = g.get_gist("004e205c856d5f934704333f5725d61e")
gist.edit(
"Description edited by PyGithub",
{"gistfile1.txt": github.InputFileContent("File also created by PyGithub")},
)这将导致这些错误。
Traceback (most recent call last):
File "/Users/boazburnett/Library/Application Support/JetBrains/PyCharmCE2022.2/scratches/scratch.py", line 9, in <module>
{"gistfile1.txt": github.InputFileContent("File also created by PyGithub")},
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/github/Gist.py", line 259, in edit
"PATCH", self.url, input=post_parameters
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/github/Requester.py", line 355, in requestJsonAndCheck
verb, url, parameters, headers, input, self.__customConnection(url)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/github/Requester.py", line 378, in __check
raise self.__createException(status, responseHeaders, output)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/reference/gists#update-a-gist"}发布于 2022-10-14 14:21:13
对于任何发现这个问题的人,您都可以使用以下代码编辑文档。
import github.InputFileContent
from github import Github
g = Github("insert access token here")
gist = g.get_gist("insert gist link here")
gist.edit(
"",
{"gistfile1.txt": github.InputFileContent("hello world")},
)确保您的访问令牌能够访问所需的一切,您需要的不仅仅是访问。
这是我制作的一个视频,里面有关于如何编辑https://youtu.be/IzmkE15AkfY的更多信息。
下面是一个带有文件和示例的github:https://github.com/msubb/python-gist
https://stackoverflow.com/questions/74058738
复制相似问题