【发布时间】:2016-03-23 12:51:49
【问题描述】:
这是来自 Google Drive v3 API 示例的代码。
定义主(): """显示 Google Drive API 的基本用法。""" 凭证 = get_credentials() http = credentials.authorize(httplib2.Http()) service = discovery.build('drive', 'v3', http=http)
results = service.files().list(q="mimeType='image/jpeg'",
pageSize=2,fields="nextPageToken, files(id, mimeType, name, description)").execute()
items = results.get('files', [])
if not items:
print('No files found.')
else:
print('Files:')
for item in items:
print('{0} {1} {2} {3}'.format(item['id'], item['mimeType'], item['name'], item['description']))
我添加了看起来像 v3 文档中的有效属性的描述。我收到此错误。
print('{0} {1} {2} {3}'.format(item['id'], item['mimeType'], item['name'], item['description']))
KeyError: '描述'
我正在使用 Python 3.0。原始示例中的代码可以在这里找到 - https://developers.google.com/drive/v3/web/quickstart/python#step_3_set_up_the_sample
文件参考的文档可以在这里找到 - https://developers.google.com/drive/v3/reference/files
【问题讨论】:
标签: python-3.x google-drive-api google-api-python-client