Python:将谷歌驱动器中的文件复制到特定文件夹中
问题描述:
我正在制作一个电子表格,我需要重新设置每个星期,我试图使用PyDrive API制作完美的文件副本与下面的代码。Python:将谷歌驱动器中的文件复制到特定文件夹中
我的问题是,我不能指定哪个文件夹我想保存副本。我想有一个名为“存档”,其中包含我所有的备份文件夹。这是可能的,使用PyDrive,如果是这样,如何?谢谢!
## Create a new Document in Google Drive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
folder = "########"
title = "Copy of my other file"
file = "############"
drive.auth.service.files().copy(fileId=file,
body={"parents": [{"kind": "drive#fileLink",
"id": folder}], 'title': title}).execute()
答
感谢来自@Rawing的评论,我想通了。它是在“文件夹”变量中指定的
+0
你现在可以[接受你自己的答案](http://stackoverflow.com/help/someone-answers)将你的问题标记为回答:) –
我非常确定您__are__指定了带'body = {“parents”[:]}'的目标文件夹'。 –
这个伎俩!非常感谢! – Soer7022