【问题标题】:Sort github API list repos by created_at date按 created_at 日期对 github API 列表存储库进行排序
【发布时间】:2018-12-03 14:33:38
【问题描述】:

我正在使用 github developer API link 列出具有给定搜索词的所有存储库,我想按created_at 日期按降序对其进行排序。我该怎么做?

【问题讨论】:

    标签: sorting github-api


    【解决方案1】:

    我自己找到了解决方案: 列出具有给定搜索词的存储库(例如 oauth):

    response = https://api.github.com/search/repositories?q=oauth&order=desc
    

    现在排序为

    # Sort based on created_at date 
    data = sorted(response.json()['items'], key=lambda x: x['created_at'], reverse = True)
    

    感谢similar post

    【讨论】:

    • 事后排序与让 API 为您排序不同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 2014-07-06
    • 2020-10-25
    相关资源
    最近更新 更多