返回所有任务不会返回已完成的任务

时间:2019-06-12 12:59:38

标签: python google-tasks-api google-tasks

我开发了一个小的命令行应用程序来带google任务,但是返回指定任务列表中的所有任务不会返回已完成的任务,希望showCompleted默认为

所以我在Live API中尝试了很多次,只返回了未完成的任务,请自行查看:https://developers.google.com/tasks/v1/reference/tasks/list

对于那些不了解的人,请转到您的Gmail,添加一个未完成的任务和一个已完成的任务,然后转到实时API并对其进行测试,即使将showCompleted设置为,您仍会看到未出现已完成的任务真正! 他们如何在Google Tasks的在线版本中完成任务?

tasks = service.tasks().list(tasklist='@default').execute()

for task in tasks['items']:
  print task['title']
  print task['status']
  print task['completed']

1 个答案:

答案 0 :(得分:1)

  • 您要使用Python检索带有和不带有“已完成”的任务列表。
  • 您已经可以使用Tasks API。

如果我的理解是正确的,那么该修改如何?

为了检索完成的任务,请按如下方式使用showHidden的属性。 showCompleted的属性默认为True。2

修改后的脚本:

从:
tasks = service.tasks().list(tasklist='@default').execute()

for task in tasks['items']:
  print task['title']
  print task['status']
  print task['completed']
至:
tasks = service.tasks().list(tasklist='@default', showHidden=True).execute()  # Modified
for task in tasks['items']:
    print(task['title'])
    print(task['status'])
    if 'completed' in task:  # Added
        print(task['completed'])
    else:
        print('not completed')

参考:

如果我误解了您的问题,而这不是您想要的结果,我深表歉意。