我正在使用适用于 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()... 有没有办法解决这个问题?