通过python访问谷歌电子表格

我想通过python连接到我的谷歌表。 这是我的代码片段。

#!/usr/bin/python import time import gdata.spreadsheet.service email = 'mymailid@gmail.com' password = 'mypass' spreadsheet_key = '1k7XK1FzGcdLdQXs8hfLn6pdWcNZiesmW6Y5eOdxtDwE' worksheet_id = 'od6' spr_client = gdata.spreadsheet.service.SpreadsheetsService() spr_client.email = email spr_client.password = password try : spr_client.ProgrammaticLogin() print "Connected to spreadsheet" except Exception as e : print "Error connecting to spreadsheet !!! ERROR : ", e dict = {} dict['date'] = time.strftime('%m/%d/%Y') dict['time'] = time.strftime('%H:%M:%S') print dict try : entry = spr_client.InsertRow(dict, spreadsheet_key, worksheet_id) print "Data entered successfully" except Exception as e : print "Could not fill the spreadsheet !!! ERROR : ", e 

1 。 首先,我用我的正确的用户名和密码尝试,但它会引发错误cElementTree.ParseError: mismatched tag: line 1254, column 4虽然我的代码只有30行。

我尝试了错误的用户名和密码。 它仍然显示Connected to spreadsheet

3.在运行spr_client.InsertRow(dict, spreadsheet_key, worksheet_id) ,出现错误Could not fill the spreadsheet ERROR : mismatched tag: line 1254, column 4

我已经从这个链接尝试所有这一切。

这个颠倒的原因可能是什么原因? 或者我错了某个地方?

看看gspread api,使用Pythonic更容易: https : //github.com/burnash/gspread 。 我有很多使用gdata.spreadshet直到find另一个。