python - 返回所有任务不返回已完成的任务
问题描述
我开发了一个带google任务的命令行小应用,但是返回指定任务列表中的所有任务不返回已完成的任务,希望showCompleted默认为true
所以我在 Live API 中尝试了很多次,只返回未完成的任务,请自行查看:https ://developers.google.com/tasks/v1/reference/tasks/list
不明白的去Gmail给你添加一个未结束的任务和一个结束的任务,然后去live API测试一下,你会发现即使你把showCompleted设置为True,也没有出现结束的任务!他们如何在 Google Tasks 的在线版本中完成任务?
tasks = service.tasks().list(tasklist='@default').execute()
for task in tasks['items']:
print task['title']
print task['status']
print task['completed']
解决方案
- 您想使用 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')
参考:
如果我误解了您的问题并且这不是您想要的结果,我深表歉意。
推荐阅读
- python - 用于在 Excel 中导出的嵌套字典顺序或 pandas 列的顺序
- sqlite - React native sqlite 如何在 Flatlist 上从数据库中呈现数据(JSON 类型)?
- java - NoClassDefFoundError 如果在主方法之外调用类
- angular - 访问 WebApi 时不允许使用 Angular 5 HTTP get 方法
- postgresql - 在数据目录从 PostgreSQL 8.4.8 升级到 PostgreSQL 9.5.2 期间,日志(很少)出现两次
- c# - 在 Visual Studio 中随机化用户代理 GeckoFX
- synchronization - Netdrive 和同步文件夹 (Nextcloud) 之间的 MS Office 锁定文件(所有者文件)行为不同
- javascript - 我可以发送文件上传的默认值吗?
- angular-material - 'mat-toolbar' 不是已知元素 - Angular 5
- php - 我有两个包含重复值和唯一值的表。我不需要两个表中的重复值,我只需要唯一值