PyGithub如何在rep中获取子文件夹的内容

2024-05-23 18:34:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试获取给定github存储库中子文件夹“github”的内容。这似乎行不通。在

repo = g.get_repo("PyGithub/PyGithub")
contents = repo.get_contents("github")
while len(contents) > 1:
    file_content = contents.pop(0)
    if file_content.type == "dir":
        contents.extend(repo.get_contents(file_content.path))
    else:
        print(file_content)

Tags: github文件夹内容getleniftypecontents