AttributeError:“函数”对象没有属性“列表”

时间:2020-09-08 21:16:18

标签: google-api-client google-apis-explorer

我的代码如下:

from pprint import pprint

from googleapiclient import discovery
from oauth2client.client import GoogleCredentials

credentials = GoogleCredentials.get_application_default()

service = discovery.build('cloudresourcemanager', 'v1', credentials=credentials)

while True:
    request = service.projects().list()
    response = request.execute()

    for project in response.get('projects', []):
        # TODO: Change code below to process each `project` resource:
        pprint(project)

我得到了错误:

Traceback (most recent call last):
  File "sample.py", line 18, in <module>
    request = service.projects.list()
AttributeError: 'function' object has no attribute 'list'

此代码在google api资源管理器网站上列出。

0 个答案:

没有答案