使用 PyDrive 指定文件下载位置?

Specify file download location using PyDrive?

我目前正在尝试使用 PyDrive 从 Google Drive 下载文件,但我只能将该文件下载到与我的 Python 程序相同的位置。有没有办法指定文件的下载位置?这就是我目前下载文件的方式。

    if file1['title'] == file_name:
      file2 = drive.CreateFile({'id': file1['id']})
      print('Downloading file %s from Google Drive' % file2['title']) 
      file2.GetContentFile(file_name)  # Save Drive file as a local file

尝试以下操作:

if file1['title'] == file_name:
      location = "Path/where/you/want/to/save/"
      """
      if you are in linux and want to save it to documents try following
      location = "~/Documents/"
      the last forward slash i.e. '/' is important
      """

      full_path = location + file_name

      file2 = drive.CreateFile({'id': file1['id']})
      print('Downloading file %s from Google Drive' % file2['title']) 
      file2.GetContentFile(full_path)