讀取到更新在結束第一 這裏是我的代碼:更新電子表格使用GDATA Python API中
spreadsheet_key = "0AhBYO002ygGgdDZQTW5pTVhLdjM4NlhHbXJ1cVRCd3c"
worksheet_id = "od6"
spr_client = gdata.spreadsheet.service.SpreadsheetsService()
spr_client.email = '[email protected]'
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)
UPDATE:此代碼固定在此之後:
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'}
@RacketDonkey 謝謝你這麼多 我現在這個錯誤: {「狀態」 400,「體」:「屬性名稱"與元素類型" NS1相關的名稱":公制"必須遵循由' = '字符。','reason':'Bad Request'} 請你幫我解決......我已經失眠太久,試圖讓這個工作.. :( –
@AniqueAkhtar尋找在錯誤代碼中,是否使用XML爲字典賦值? – RocketDonkey
Nop ... 我很難編碼它... Jus t像我給你看的方式.. 但我使用的是Django ... –