2013-02-14 49 views
1

我正在写谷歌应用程序引擎的excel文件,我得到以下错误,最新错误的代码?UnicodeDecodeError在谷歌应用程序引擎python

UnicodeDecodeError: 'utf8' codec can't decode byte 0xd0 in position 706: invalid continuation byte 

下面是代码,

myworkbook = xlwt.Workbook() 
ws = myworkbook.add_sheet('Sheet1') 
ws.write(0, 0, 'Cell of my sheet') 
myworkbook.save(self.response.out) 
self.response.headers['Content-Type'] = 'application/excel' 
self.response.out.write(self.response.out) 
+0

你为什么把'self.response.out'写回'self.response.out'?你已经写出'myworkbook'给响应流.. – 2013-02-14 08:35:20

+0

我将exel文件的输出保存到'self.response.out',然后写'self.response.out'输出。这就是为什么。 – fledgling 2013-02-14 08:46:16

+0

而你没有看到那个问题是什么? – 2013-02-14 08:47:08

回答

1

您需要删除以下行:

self.response.out.write(self.response.out) 

myworkbook.save(self.response.out)已经呼吁self.response.out.writeself.response.out是一个文件对象;写到self.response.out再次没有意义。