首先阅读最后的更新这是我的代码:
spreadsheet_key = "0AhBYO002ygGgdDZQTW5pTVhLdjM4NlhHbXJ1cVRCd3c"
worksheet_id = "od6"
spr_client = gdata.spreadsheet.service.SpreadsheetsService()
spr_client.email = 'myemail@gmail.com'
spr_client.password = '<pwd>'
spr_client.source = 'Example Spreadsheet Writing Application'
spr_client.ProgrammaticLogin()
dicti = {}
dicti['Name'] = 'A'
dicti['Metric Name'] = 'A2'
dicti['Completed Units'] = 10
dicti['Team Size'] = 2
entry = spr_client.InsertRow(dicti, spreadsheet_key, worksheet_id)
每次我运行此代码时,最后一次都会出现此错误:
'int' object has no attribute 'decode'
请告诉我应该如何进行...
这是 InsertRow 函数中出现错误的地方:
/usr/local/lib/python2.7/site-packages/gdata/spreadsheet/service.py in InsertRow
new_custom.column = k
new_custom.text = v
new_entry.custom[new_custom.column] = new_custom
# Generate the post URL for the worksheet which will receive the new entry.
post_url = 'https://spreadsheets.google.com/feeds/list/%s/%s/private/full'%(
key, wksht_id)
return self.Post(new_entry, post_url,
converter=gdata.spreadsheet.SpreadsheetsListFromString)
更新:将此代码修复为:
dicti = {}
dicti['Name'] = 'A'
dicti['Metric Name'] = 'A2'
dicti['Completed Units'] = '10'
dicti['Team Size'] = '2'
我现在收到此错误:
{'status': 400, 'body': 'Attribute name "Name" associated with an element type "ns1:Metric" must be followed by the ' = ' character.', 'reason': 'Bad Request'}