【问题标题】:Accessing google spreadsheet through python通过python访问谷歌电子表格
【发布时间】: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


    【解决方案1】:

    看看gspread api,它更容易使用和Pythonic:https://github.com/burnash/gspread。在找到另一个之前,我使用gdata.spreadshet 遇到了很多麻烦。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-09
      • 1970-01-01
      • 2013-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多