Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Github3.py 1.3.0获取提交的时间戳_Python_Github_Github3.py - Fatal编程技术网

Python Github3.py 1.3.0获取提交的时间戳

Python Github3.py 1.3.0获取提交的时间戳,python,github,github3.py,Python,Github,Github3.py,我浏览了文档甚至源代码,但似乎不知道如何使用github3.py库获取提交的时间戳。我很确定它在那里,因为它是一个时间戳 因此,如果您想获得与GitHub中存储的git提交相关的时间戳,那么您需要具备以下几项: 包含提交的存储库 沙 您定义的时间戳(是它被编写的日期时间,或者它被提交的日期时间-注意,这些并不总是保证相等) 因此,如果您拥有存储库,您可以这样检索它: repo = github3.repository('username', 'repositoryname') 有了它,您应

我浏览了文档甚至源代码,但似乎不知道如何使用github3.py库获取提交的时间戳。我很确定它在那里,因为它是一个时间戳

因此,如果您想获得与GitHub中存储的git提交相关的时间戳,那么您需要具备以下几项:

  • 包含提交的存储库
  • 您定义的时间戳(是它被编写的日期时间,或者它被提交的日期时间-注意,这些并不总是保证相等)
因此,如果您拥有存储库,您可以这样检索它:

repo = github3.repository('username', 'repositoryname')
有了它,您应该能够获得如下所示的
git_commit
数据:

commit = repo.git_commit('sha1-of-git-commit-i-care-about')
您的
commit
值是一个对象的实例,该对象具有
author
committer
属性,这些属性是类似于

  "author": {
    "date": "2014-11-07T22:01:45Z",
    "name": "Scott Chacon",
    "email": "schacon@gmail.com"
  },
  "committer": {
    "date": "2014-11-07T22:01:45Z",
    "name": "Scott Chacon",
    "email": "schacon@gmail.com"
  },
因此,您可以用以下内容来总结:

commit.author["date"]

我建议使用类似于
dateutil
的实用程序来解析这些时间戳。

弃用警告:匿名API函数
github3.API.repository
已弃用。改用
GitHub.repository