我正在尝试使用BigQuery API Python库访问数据,但似乎无法这样做。我的代码如下。我在代码中使用的数据也使用了here,并且在那里起作用,但是在我的代码中抛出了TypeError: 'HttpRequest' object has no attribute '__getitem__'错误。

如果我只是执行print response,则输出为<googleapiclient.http.HttpRequest object at 0x1031d0d50>

任何帮助都感激不尽。

from apiclient.discovery import build
import logging
from oauth2client.client import GoogleCredentials
logging.basicConfig()
credentials = GoogleCredentials.get_application_default()
bigquery_service = build('bigquery', 'v2', credentials=credentials)
tables = bigquery_service.tables()
response= tables.get(projectId=project_id, datasetId=dataset_id, tableId=table_id)
print response['kind'] #causes TypeError: 'HttpRequest' object has no attribute '__getitem__'

最佳答案

LN 8末尾缺少.execute()

[..]
response= tables.get(projectId=project_id, datasetId=dataset_id, tableId=table_id).execute()
[..]

07-28 02:28
查看更多