在googlekeep-gkeepapi中排序注释

2024-04-26 08:06:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我查看了文档中的gkeepapi,没有任何函数可以对注释进行排序。但是,注释显示在“保持”中,顺序如下:

import gkeepapi
k = gkeeapi.Keep()
k.login('xxxxx@gmail.com', pwd)

gnotes = k.keep.find(pinned=False, trashed=False)
for n in gnotes:
    print(n.title)

gnotes = sorted(gnotes, key=lambda x: x.title)
k.sync()

我正在寻找按标题分类的侏儒然后更新它,这样当我在谷歌看到我的笔记是按字母顺序排序的。在


Tags: 函数文档importcomfalse排序顺序title
1条回答
网友
1楼 · 发布于 2024-04-26 08:06:36

因为我不能调用googlenotesapi,所以我使用了一个注释替换。在

class Note:
    def __init__(self, title, other):
        self.title = title
        self.other = other

    def __repr__(self):
        return '{} - {}'.format(self.title, self.other)


gnotes = [Note('OneTitle', 'bla'), Note('Ztitle', 'bla'), Note('BTitle', ',bla')]
gnotes = sorted(gnotes, key=lambda x: x.title)
# gnotes = k.keep.find(pinned=False, trashed=False)
for note in gnotes:
    print(note)

输出

^{pr2}$

相关问题 更多 >