from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
import random
import msvcrt
import json
credentials_doc = 'service_account.json'
service_account_info = json.load(open(credentials_doc))
credentials = Credentials.from_service_account_info(service_account_info)
service = build('drive', 'v3', credentials=credentials)
document_id='my_doc_drive_id'
document = service.comments().get(documentId=document_id).execute()
print(document)
错误: 文档 = service.comments().get(documentId=document_id).execute() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ raise TypeError("得到一个意外的关键字参数 {}".format(name)) 类型错误:获得意外的关键字参数 documentId
我怎样才能得到我的文件 ** 驱动器链接:https://docs.google.com/document/d/my_doc_drive_id**
我想获取我的驱动器文档信息并处理传入信息
从
how can i get my document ** drivelink:https://docs.google.com/document/d/my_doc_drive_id**
和I want to get my drive doc infos and processing incomings
,我相信你的目标如下。
document_id='my_doc_drive_id'
的 Google 文档。fileId
和commentId
。从你的问题来看,我猜你的document_id='my_doc_drive_id'
可能是Google文档ID,而不是评论ID。我猜这可能是您当前问题的原因。如果您想检索Google文档,则需要使用Google Docs API。
from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
import json
credentials_doc = 'service_account.json'
service_account_info = json.load(open(credentials_doc))
credentials = Credentials.from_service_account_info(service_account_info)
service = build('docs', 'v1', credentials=credentials)
document_id='my_doc_drive_id' # Please set your Google Document ID.
document = service.documents().get(documentId=document_id).execute()
print(document)
document_id='my_doc_drive_id'
的文档时,将从 Google 文档中检索对象。如果你想使用Drive API检索Google Documents的文件元数据,我认为可以使用以下脚本。
from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
import json
credentials_doc = 'service_account.json'
service_account_info = json.load(open(credentials_doc))
credentials = Credentials.from_service_account_info(service_account_info)
service = build("drive", "v3", credentials=credentials)
document_id='my_doc_drive_id' # Please set your Google Document ID.
document = service.files().get(fileId=document_id, fields="*").execute()
print(document)