EDITすべきではない。ここでは、メタデータにアクセスし、取得し、その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をご覧ください。
あなたはIDがある
- が
- 、
=
兆候を囲む独自のスペースを導入しないでくださいPyDriveは、GoogleドライブのAPI V2を使用していますので、あなたの代わりにthe v2 search parameter pageを使用していることを確認、
- ていることを確認してくださいGoogleドライブで割り当てられたフォルダID、this SO questionにはIDの検索方法が記載されています。たとえば、
:
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']))
質問がありますか?または目的? – Ukimiku
私は関数を実行する必要があります – simone989
"[...]とは何を意味しますか?それは何であってはなりませんか? –