【发布时间】:2016-04-28 07:23:22
【问题描述】:
我正在尝试通过 python 连接到我的谷歌表格。这是我的代码 sn-p。
#!/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 行。
2.我尝试了错误的用户名和密码。它仍然显示Connected to spreadsheet。
3.在运行spr_client.InsertRow(dict, spreadsheet_key, worksheet_id)时,抛出错误Could not fill the spreadsheet ERROR : mismatched tag: line 1254, column 4
我已经通过this 链接尝试了所有这些。
这种颠倒的原因可能是什么。还是我哪里错了?
【问题讨论】:
标签: python excel google-sheets