Python中Google驱动API请求的语法

Python中Google驱动API请求的语法,python,google-drive-api,Python,Google Drive Api,第一次尝试在Python中使用GoogleDriveAPI 此脚本列出了我的Google Drive文件夹中的文件 from __future__ import print_function from apiclient import discovery from httplib2 import Http from oauth2client import file, client, tools SCOPES = 'https://www.googleapis.com/auth/drive.r

第一次尝试在Python中使用GoogleDriveAPI

此脚本列出了我的Google Drive文件夹中的文件

from __future__ import print_function

from apiclient import discovery
from httplib2 import Http
from oauth2client import file, client, tools

SCOPES = 'https://www.googleapis.com/auth/drive.readonly.metadata'
store = file.Storage('storage.json')
creds = store.get()
if not creds or creds.invalid:
    flow = client.flow_from_clientsecrets('client_id.json', SCOPES)
    creds = tools.run_flow(flow, store)
DRIVE = discovery.build('drive', 'v3', http=creds.authorize(Http()))

# List files Google Drive
files = DRIVE.files().list().execute().get('files', [])
for f in files:
    print(f['name'], f['mimeType'], f['sharedWithMeTime'])
在阅读过程中,我对这里的语法感到困惑:

files = DRIVE.files().list().execute().get('files', [])
我(认为我)理解的是:

  • DRIVE
    是驱动器实例
  • 文件如所述
  • 如前所述,可以在文件上调用列表 我不明白的是:

  • 通过阅读文档,我怎么知道
    文件
    是一种方法
  • 列表相同
  • 什么是
    execute()
    ,通过阅读文档我如何知道如何使用它
  • 对于
    get()
  • 在哪里可以找到传递到
    get()
    的参数的说明

  • 顺便说一句,我想
    execute()
    执行请求,然后
    get()
    发出HTTP get请求。但是,我想从文档中了解它,以便正确地使用它们

    我建议从开始,因为您当前的文件似乎混合了files.list和files.get。那你就有官员了