尝试从python向谷歌电子表格添加行.无法计算数据参数的长度.为"内容长度"指定一个值



尝试从python代码向Google电子表格添加行会引发错误。

Traceback (most recent call last):
File      "/Users/M/Desktop/s.py",   line 360, in <module>
main()
File  "/Users/M/Desktop/s.py",  line 346, in main
client.ProgrammaticLogin()
File "/Users/M/Desktop/src/gdata/src/gdata/service.py",   line 752, in ProgrammaticLogin
headers={'Content-Type': 'application/x-www-form-urlencoded'})
File "/Users/M/Desktop/src/gdata/src/atom/http.py", line   98, in request
raise atom.http_interface.ContentLengthRequired('Unable to  calculate '
atom.http_interface.ContentLengthRequired: Unable to calculate the     length of the data parameter. Specify a value for Content-Length

我正在使用以下代码:https://nirvanatikku.tumblr.com/post/61232391054/inserting-rows-into-a-google-spreadsheet-with

import gdata.spreadsheet.service
email = ''
password = ''
spreadsheet_key = 'test' # key param
worksheet_id = 'od6' # default
def main():
client = gdata.spreadsheet.service.SpreadsheetsService()
client.debug = True
client.email = email
client.password = password
client.source = 'test client'
client.ProgrammaticLogin()
rows = []
rows.append({'id':'0','title':'First'})
rows.append({'id':'1','title':'Second'})
for row in rows:
try:
client.InsertRow(row, spreadsheet_key, worksheet_id)
except Exception as e:
print e
return

错误在"客户端。编程登录((" 有谁知道如何解决它?

晚了将近一年,但我发现这个: http://sapsicoblog.appspot.com/2015/02/GData-ProgrammaticLogin-using-Google-ClientLogin-going-to-stop-working-on-April-20-2015

ProgrammaticLogin(( 已于 2015 年 4 月 20 日弃用。 建议改用 oAuth2

。看到这个: Gdata python Google Apps 身份验证

相关内容

最新更新