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