小编Dha*_*a M的帖子

python:如何使用api从Google驱动器下载文件

我想使用Google Drive API将Google Drive中的文件下载到我的系统中。我该如何实施呢?

根据https://developers.google.com/drive/v2/reference/files/get#examples中给出的示例

def print_file(service, file_id):

 """Print a file's metadata.

  Args:
    service: Drive API service instance.
    file_id: ID of the file to print metadata for.
  """
  try:
    file = service.files().get(fileId=file_id).execute()

    print 'Title: %s' % file['title']
    print 'MIME type: %s' % file['mimeType']
  except errors.HttpError, error:
    print 'An error occurred: %s' % error


def download_file(service, drive_file):
  """Download a file's content.

  Args:
    service: Drive API service instance.
    drive_file: Drive File instance.

  Returns:
    File's content if successful, None otherwise.
  """ …
Run Code Online (Sandbox Code Playgroud)

python-2.7 google-drive-api

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

google-drive-api ×1

python-2.7 ×1