Python中Google驱动API请求的语法
第一次尝试在Python中使用GoogleDriveAPI 此脚本列出了我的Google Drive文件夹中的文件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
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。那你就有官员了