cuốn sách gpt4 ai đã làm

python - Cách xóa tài nguyên khỏi bộ sưu tập gốc (thư mục) (Tài liệu Google Docs)

In lại Tác giả: Vũ trụ không gian Thời gian cập nhật: 2023-11-03 19:07:06 25 4
mua khóa gpt4 Nike

我正在使用 python gdata 库复制并移动特定文件夹中的 google Docs 文件。我正在使用 DocsClient 中的 MoveResource 方法,该文件出现在所需的文件夹中,但也保留在根文件夹中。

我不知道如何将其从根文件夹中删除?!

import gdata.docs.service
import gdata.docs.client
import gdata.docs.data

doc_service = gdata.docs.client.DocsClient()
doc_service.ClientLogin('myId', 'myPassword', 'myAppName')

# this is my source document
doc = doc_service.GetResourceById('ABC123')

# extracting the folder of my source document to move the copy in the same folder
for parent in doc.InCollections():
if parent.title == 'myFilter':
destination_folder_id = parent.href.split('%3A')[1]
destination_folder = doc_service.GetResourceById(destination_folder_id)

# making a copy of my source
newdoc = doc_service.CopyResource(doc, 'Test Python')

# moving my copy to the same folder as my source
# but the copy also stays in the root folder!
moveddoc = doc_service.MoveResource( newdoc, destination_folder )

câu trả lời hay nhất

您可以使用以下代码从根集合中删除 Google 文档文件:

doc_service.Delete('https://docs.google.com/feeds/default/private/full/folder%3Aroot/contents/' + doc.resource_id.text, force=True)

关于python - 如何从根集合(文件夹)中删除资源(Google Docs 文档),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14445040/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress