使用Python googleapiclient将数据写入Google表格

我是googleapiclient的新手。现在,我想出了代码,以使用certificate.json和token.pickle将数据从GSheet获取到S3。

scope = ['https://www.googleapis.com/auth/spreadsheets.readonly']
credentials = get_google_token(scope=scope,token_file=token_file,cred_file=cred_file)
service = build('sheets','v4',credentials=credentials,cache_discovery=False)

range_name = sheet_title + '!' + sheet_range_name

# Call the Sheets API
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId=spreadsheetId,range=range_name
                            ).execute()

当我尝试更新记录时(反之亦然),我无法授权Http,并且我不知道如何处理“使用Google API Client编写Google Sheet”。

scope = ['https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
credentials = get_google_token(scope=scope,cred_file=cred_file)
print(credentials)
service = build('sheets',credentials=credentials)
print(service)
values = {'values':[['Hello World',],]}
range_name = sheet_title + '!' + sheet_range_name

# Call the Sheets API to Update the Value
result = service.spreadsheets().values().update(spreadsheetId=spreadsheetId,range=sheet_range_name,valueInputOption='RAW',body=values).execute()
taoguolin 回答:使用Python googleapiclient将数据写入Google表格

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3065875.html

大家都在问