0

对不起我的英语不好,我是 pydrive 用户的初学者。现在我正在尝试从我的谷歌驱动器中获取所有文件名。这是我的驱动器.py:

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.CommandLineAuth()
drive = GoogleDrive(gauth)

file1 = drive.CreateFile({'title': 'Hello.txt'})  # Create GoogleDriveFile instance with title 'Hello.txt'.
file1.SetContentString('Hello World!') # Set content of the file from given string.
file1.Upload()

for file_list in drive.ListFile({'q': "'root' in parents and trashed=false"}):
  print('Received %s files from Files.list()' % len(file_list)) # <= 10
  for file1 in file_list:
      print('title: %s, id: %s' % (file1['title'], file1['id']))

这是我的设置文件:

client_config_backend: settings
client_config:
  client_id: XXXX
  client_secret: YYYYY

save_credentials: True
save_credentials_backend: file
save_credentials_file: credentials.json

get_refresh_token: True

oauth_scope:
  - https://www.googleapis.com/auth/drive.file
  - https://www.googleapis.com/auth/drive.install
  - https://www.googleapis.com/auth/drive.metadata

结果是:

Received 1 files from Files.list()    
title: Hello.txt, id: xxxxxx

问题是,我只能获取上面创建的文件“hello.txt”,而不仅仅是从 goole 驱动器中的 web 界面创建的。我的设置文件或查询中有什么问题吗?

再次为我糟糕的英语感到抱歉,希望每个人都有美好的一天。

4

0 回答 0