You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用pygithub按Jupyter Notebook语言过滤GitHub仓库搜索?

Solution for Filtering Jupyter Notebook Repos with PyGitHub

Hey there! I’ve dealt with this exact problem before, so let me walk you through fixing it.

Why Your Previous Queries Failed

GitHub’s search engine treats language names with spaces as a single, unified term. When you tried variations like language:JupyterNotebook or language:Jupyter, you weren’t matching the official label GitHub uses for Jupyter Notebook files—"Jupyter Notebook" (with a space included). Without wrapping that spaced name in quotes, GitHub interprets it as separate keywords, which doesn’t return the results you want.

The Correct Query Syntax

To target Jupyter Notebook repositories properly, you need to wrap the full language name in quotes within your search query. This tells GitHub to treat it as a single, exact match.

Updated Code

Here’s how to adjust your PyGitHub script to get the right results:

from github import Github
g = Github("login", "password")
# Wrap "Jupyter Notebook" in quotes to preserve the space in the language name
repositories = g.search_repositories(query='Self organizing map language:"Jupyter Notebook"')
for repo in repositories:
    # Replace with your custom processing logic
    print(f"Repo: {repo.name} | URL: {repo.html_url}")

Why This Works

  • GitHub’s API requires quoted strings for language names that include spaces to ensure exact matches. This is the same rule that applies when using GitHub’s web search bar.
  • If you test language:"Jupyter Notebook" directly on GitHub’s web search, you’ll see it correctly pulls up repositories with .ipynb files—this translates perfectly to the PyGitHub query since the library passes your query string straight to GitHub’s backend.

Bonus: Alternative Filter by File Extension

If you want to be even more precise (e.g., find repos with .ipynb files even if Jupyter Notebook isn’t listed as the primary language), you can filter by file extension instead:

repositories = g.search_repositories(query='Self organizing map filename:*.ipynb')

内容的提问来源于stack exchange,提问作者Sergey Vladimirovich

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:55:03