Here 下
"更新文件元数据"它显示了如何从创建的文件更改标题。如果我知道id或密钥,我正在寻找如何更改标题。或者有没有办法在gspread
?
答案 0 :(得分:4)
您也可以直接使用PyDrive执行此操作。 CreateFile()仅创建一个本地Python对象来表示新文件或现有文件的状态
# CreateFile() can be called with an existing id.
file1 = drive.CreateFile({'id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'})
file1['title'] = '<new title>' # Change title.
file1.Upload() # Upload new title.
答案 1 :(得分:1)
我找到了
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
id='xxxxxxxxxxxxxxxxxxxxxxxx'
a=drive.auth.service.files().get(fileId=id).execute()
a['title']="new title"
update=drive.auth.service.files().update(fileId=id,body=a).execute()