在Python中获取PaginatedList的最后一个元素

joy*_*eba 4 python list arraylist

如何获取 PaginationList 的最后一个元素?#

( <github.PaginatedList.PaginatedList object at 0x7f1c6a492a50>)。

我的代码是这样的 - a_project_column.get_cards()[-1]错误是

“索引错误:列表索引超出范围”

但下面的代码可以正常工作以获得所需的结果(即>>ProjectCard(id = 5161717))

a_project_column.get_cards()[0]

供参考 https://github.com/PyGithub/PyGithub/blob/master/github/PaginatedList.py

小智 5

我知道已经有一段时间了,但我找到了解决方案,我想我会把它提供给任何应该像我一样去谷歌搜索的人,但无济于事:

代替

a_project_column.get_cards()[-1]
Run Code Online (Sandbox Code Playgroud)

尝试:

cards = a_project_column.get_cards()
final_card  = cards[cards.totalCount - 1]
Run Code Online (Sandbox Code Playgroud)