Python 尝试将电子邮件写入google sheet时出错 导入gspread 电子邮件=['test@test.com' , 'test1@test1.com'] def api(密钥): gc=gspread.service\u帐户(filename='Auth.json') sh=gc。按键打开(键) 工作表=sh.get_工作表(1) 工作表。插入_行([“电子邮件”],1) 工作表。插入_行(电子邮件,2) api(“myapi”)

Python 尝试将电子邮件写入google sheet时出错 导入gspread 电子邮件=['test@test.com' , 'test1@test1.com'] def api(密钥): gc=gspread.service\u帐户(filename='Auth.json') sh=gc。按键打开(键) 工作表=sh.get_工作表(1) 工作表。插入_行([“电子邮件”],1) 工作表。插入_行(电子邮件,2) api(“myapi”),python,google-sheets,google-sheets-api,gspread,Python,Google Sheets,Google Sheets Api,Gspread,错误: 我无法将电子邮件列表写入google工作表行,因为我不断收到以下错误: 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.g

错误: 我无法将电子邮件列表写入google工作表行,因为我不断收到以下错误:

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"'}]}]}

我相信你的目标如下

  • 您想将
    []的值test@test.com' , 'test1@test1.com“]
    添加到插入的行
在这种情况下,我认为在这种情况下,
['test@test.com' , 'test1@test1.com']
必须是二维数组,如
[[]test@test.com'], ['test1@test1.com']]
。我认为错误的原因就是这个。所以请修改如下,并再次测试它

发件人: 致: 参考资料:
emails = ['test@test.com' , 'test1@test1.com']
emails = [['test@test.com'], ['test1@test1.com']]