这个功能:
drive.ListFile({'q': " id = '"+Value+"' and trashed=false"}).GetList()
返回:“查询无效”
问题在于选择器'id',如果我提出这个条件,我会返回一个带有'id'参数的字典
我用这个文档, https://developers.google.com/drive/v2/reference/files/list 和 https://developers.google.com/drive/v3/web/search-parameters
它适用于其他选择器,但'id'不应该是
答案 0 :(得分:3)
编辑:以下是访问元数据的方法,以及如何通过ID获取和设置现有文件的内容。
# Calling CreateFile() with an existing ID links it to the already existing file.
gdrive_file = drive.CreateFile({'id': '<your file id>'})
gdrive_file.FetchMetadata() # Only needed if you want to view or edit its metadata.
# Do things with metadata here as needed.
gdrive_file.GetContentFile('dog.png') # Download content file.
# And/or upload a new content file.
gdrive_file.SetContentFile('cat.png')
gdrive_file.Upload()
当然,docs有很多例子。
<强>原始强>: 请查看docs for file listings示例。
确保你
=
标志例如:
from pydrive.drive import GoogleDrive
drive = GoogleDrive(gauth) # Create GoogleDrive instance with authenticated GoogleAuth instance
folder_id = "insert your folder ID here"
# Auto-iterate through all files in the specified folder.
file_list = drive.ListFile({
'q': "{id} in parents and trashed=false".format(id=folder_id)
}).GetList()
for file1 in file_list:
print('title: %s, id: %s' % (file1['title'], file1['id']))
答案 1 :(得分:1)
id
不是用于执行文件搜索的受支持查询字段。
查看文档for Drive API v2,查看要搜索的有效字段。