【发布时间】:2020-09-01 22:52:16
【问题描述】:
import gspread
emails = ['test@test.com' , 'test1@test1.com']
def api(key):
gc = gspread.service_account(filename='Auth.json')
sh = gc.open_by_key(key)
worksheet = sh.get_worksheet(1)
worksheet.insert_row(["Emails"], 1)
worksheet.insert_rows(emails, 2)
api("myapi")
错误: 我无法将电子邮件列表写入 google sheet 行,因为我不断收到以下错误:
gspread.exceptions.APIError: {'code': 400, 'message': 'Invalid value at \'data.values[0]\' (type.googleapis.com/google.protobuf.ListValue), "test@test.com"\nInvalid value at \'data.values[1]\' (type.googleapis.com/google.protobuf.ListValue), "test1@test1.com"', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'data.values[0]', 'description': 'Invalid value at \'data.values[0]\' (type.googleapis.com/google.protobuf.ListValue), "test@test.com"'}, {'field': 'data.values[1]', 'description': 'Invalid value at \'data.values[1]\' (type.googleapis.com/google.protobuf.ListValue), "test1@test1.com"'}]}]}
【问题讨论】:
标签: python google-sheets google-sheets-api gspread