【发布时间】:2012-07-23 04:24:49
【问题描述】:
我正在使用适用于 Python 的 Google App Engine,但我收到一个 unicode 错误,有没有办法解决它? 这是我的代码:
def get(self):
contents = db.GqlQuery("SELECT * FROM Content ORDER BY created DESC")
output = StringIO.StringIO()
with zipfile.ZipFile(output, 'w') as myzip:
for content in contents:
if content.code:
code=content.code
else:
code=content.code2
myzip.writestr("udacity_code", code)
self.response.headers["Content-Type"] = "application/zip"
self.response.headers['Content-Disposition'] = "attachment; filename=test.zip"
self.response.out.write(output.getvalue())
我现在收到一个 unicode 错误:
UnicodeDecodeError:“ascii”编解码器无法解码位置 12 中的字节 0xf7:序数不在范围内 (128)
我相信它来自 output.getvalue()... 有没有办法解决这个问题?
【问题讨论】:
-
如果您包含完整的堆栈跟踪,我们将不必猜测错误发生的位置 - 堆栈跟踪会告诉您。
标签: python google-app-engine unicode