python - 名称错误 : name 'build' is not defined

标签 python python-3.x google-calendar-api

我正在尝试编写一个 python 脚本来从 Google 日历中获取条目。

我收到以下行的 NameError: name 'build' is not Defined:

service = build('日历','v3',credentials=credentials)

对于如何解决这个问题有什么建议吗?

最佳答案

您可以使用Python Quickstart for Calendar API作为引用。

在导入部分注意构建方法源自哪个模块:

from __future__ import print_function
from apiclient.discovery import build //notice the build here
from httplib2 import Http
from oauth2client import file, client, tools
import datetime

在此使用之前:

service = build('calendar', 'v3', http=creds.authorize(Http()))

关于python - 名称错误 : name 'build' is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51488811/

相关文章:

python - Selenium 脚本向元素返回 null

Python abstract property() "Can' t 用抽象方法实例化抽象类 []”,但我做到了

python-3.x - 如何通过匹配 Pandas 中两个不同数据帧中的列来更新一个数据帧的列

python - Numpy lomax 均值函数返回 "inf"而不是值

android - 如何在 Android 设备上访问用户的日历?

google-calendar-api - 获取刷新 token 谷歌API

python - 如何使用阿里巴巴ODPS python SDK中的Schema.from_lists方法创建schema?

python - 在字典中,如何切出特殊值

java - 我无法使用 Maven 找到 com.google.api.client.util.Preconditions 的依赖项

python下划线函数名