【发布时间】:2019-06-23 18:36:30
【问题描述】:
我查看了gkeepapi 的文档,但没有任何功能可以对笔记进行排序。然而,这些注释确实会按照此处打印的顺序出现在 Keep 中:
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()
我希望按标题对 gnotes 进行排序,然后对其进行更新,以便当我查看 Google Keep 时,我的笔记按字母顺序排序。
【问题讨论】:
-
您的
gnotes是一个局部变量。您首先从原始(未排序的)笔记列表中对其进行初始化,然后重新分配该列表的排序版本。没有什么可以将该局部变量与 Keep 服务联系起来,因此同步没有效果我并不感到惊讶。使用gnotes.sort对列表进行就地排序的可能性非常会得到同步,但find的三个结果很可能会返回数据的独立副本。阅读 API 我发现了用于排序列表项的代码,但不是用于注释的代码。可能需要等到 Google 发布 Keep 的公共 API。
标签: python google-keep