【发布时间】:2014-03-08 09:38:15
【问题描述】:
我正在将从作业 API 获取的数据写入 Google 电子表格。在对“latin-1”进行编码之后,会一直编码到第 93 页,但当达到 94 时,它会进入异常状态。我使用了不同的以下技术,但“latin-1”做了最大分页。其他人已被评论(因为他们死在第 65 页)。您能否告诉我如何修改未注释的(即 .encode('latin-1')) 以在电子表格上安全地写入 199 页? 代码如下: 在这方面的任何指导方针都提前表示赞赏。
def append_data(self,worksheet,row,start_row, start_col,end_col):
r = start_row #last_empty_row(worksheet)
j = 0
i = start_col
while (i <= end_col):
try:
worksheet.update_cell(r,i,unicode(row[j]).encode('latin-1','ignore'))
#worksheet.update_cell(r,i,unicode(row[j]).decode('latin-1').encode("utf-
16"))
#worksheet.update_cell(r,i,unicode(row[j]).encode('iso-8859-1'))
#worksheet.update_cell(r,i,unicode(row[j]).encode('latin-1').decode("utf-
8"))
#worksheet.update_cell(r,i,unicode(row[j]).decode('utf-8'))
#worksheet.update_cell(r,i,unicode(row[j]).encode('latin-1', 'replace'))
#worksheet.update_cell(r,i,unicode(row[j]).encode(sys.stdout.encoding,
'replace'))
#worksheet.update_cell(r,i,row[j].encode('utf8'))
#worksheet.update_cell(r,i,filter(self.onlyascii(str(row[j]))))
except Exception as e:
self.ehandling_obj.error_handler(self.ehandling_obj.SPREADSHEET_ERROR,[1])
try:
worksheet.update_cell(r,i,'N/A')
except Exception as ee:
y = 23
j = j + 1
i = i + 1
【问题讨论】:
-
有问题的单元格中有什么,回溯是什么样的?
标签: python excel oop google-sheets