首页 > 解决方案 > 如何通过python将图像上传到github?

问题描述

我正在尝试将图像从 python 上传到 github,如下所示:

from github import Github
import os
import cv2

token = os.getenv('GITHUB_TOKEN', '...')
g = Github(token)
repo = g.get_repo("path/repo")

content = cv2.imread("/path/to/image.jpeg'")

git_file = 'image.jpeg'
repo.create_file(git_file, "committing files", content, branch="master")

我收到了这个错误:

assert isinstance(content, (str, bytes))
AssertionError

标签: pythongitpygithub

解决方案


推荐阅读