小编fei*_*ong的帖子

如何按显示顺序获取数据库的行?

我有一些 Python 代码,可以使用notion-client 库检索 Notion 数据库中的行。该代码确实设法检索所有行,但顺序错误。我查看了API 参考中的Sort 对象,但无法弄清楚如何使用它以行在 notion.so 上显示的确切顺序返回行。这是有问题的片段:

from notion_client import Client

notion = Client(auth=NOTION_API_TOKEN)
result = notion.databases.query(database_id='...')
for row in result['results']:
  title = row['properties']['NAME_OF_PROPERTY']['title']
  if len(title) == 0:
    print('')
  else:
    print(title[0]['plain_text'])
Run Code Online (Sandbox Code Playgroud)

我缺少什么?

python notion-api

15
推荐指数
1
解决办法
3356
查看次数

标签 统计

notion-api ×1

python ×1