如何使用 google 文档 api (Python) 更新 google 文档
How to update google doc using google docs api (Python)
我是 Google Docs api 的新手,希望能够使用 replaceText 选项添加文本。我将如何设置它?我在 Python 3.6
中这样做
只需按照 Google 文档 API quickstart using Python. Then try to run this code to insert text using InsertTextRequest
方法中的步骤操作即可:
requests = [
{
'insertText': {
'location': {
'index': 25,
},
'text': text1
}
},
{
'insertText': {
'location': {
'index': 50,
},
'text': text2
}
},
{
'insertText': {
'location': {
'index': 75,
},
'text': text3
}
},
]
result = service.documents().batchUpdate(
documentId=DOCUMENT_ID, body={'requests': requests}).execute()
要将文本插入文档,请使用 BatchUpdate
方法并包含一个 InsertTextRequest
并将文本和位置作为有效负载。最好使用文档中推荐的这个方法。
我是 Google Docs api 的新手,希望能够使用 replaceText 选项添加文本。我将如何设置它?我在 Python 3.6
中这样做只需按照 Google 文档 API quickstart using Python. Then try to run this code to insert text using InsertTextRequest
方法中的步骤操作即可:
requests = [
{
'insertText': {
'location': {
'index': 25,
},
'text': text1
}
},
{
'insertText': {
'location': {
'index': 50,
},
'text': text2
}
},
{
'insertText': {
'location': {
'index': 75,
},
'text': text3
}
},
]
result = service.documents().batchUpdate(
documentId=DOCUMENT_ID, body={'requests': requests}).execute()
要将文本插入文档,请使用 BatchUpdate
方法并包含一个 InsertTextRequest
并将文本和位置作为有效负载。最好使用文档中推荐的这个方法。