为什么我在生产中得到这个UnicodeEncodeError而不是在开发中? App Engine Python

时间:2012-10-03 23:10:57

标签: python google-app-engine

我知道之前已经多次询问这个问题,我可能会得到这个问题的支持 但我尝试了很多事情却没有成功。

我的申请正在制作中。

我收到了这个错误:

2012-10-03 15:08:29.385 'ascii' codec can't encode character u'\xed' in position 2: ordinal not in range(128) Traceback (most recent call last): File "/base/python27_runtim
E 2012-10-03 15:08:29.447 Traceback (most recent call last):
E 2012-10-03 15:08:29.447 File "/base/python27_runtime/python27_dist/lib/python2.7/wsgiref/handlers.py", line 85, in run
E 2012-10-03 15:08:29.447 self.result = application(self.environ, self.start_response)
E 2012-10-03 15:08:29.447 File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1519, in __call__
E 2012-10-03 15:08:29.447 response = self._internal_error(e)
E 2012-10-03 15:08:29.447 File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
E 2012-10-03 15:08:29.447 rv = self.handle_exception(request, response, e)
E 2012-10-03 15:08:29.447 File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
E 2012-10-03 15:08:29.447 rv = self.router.dispatch(request, response)
E 2012-10-03 15:08:29.447 File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
E 2012-10-03 15:08:29.447 return route.handler_adapter(request, response)
E 2012-10-03 15:08:29.447 File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
E 2012-10-03 15:08:29.447 return handler.dispatch()
E 2012-10-03 15:08:29.447 File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
E 2012-10-03 15:08:29.447 return self.handle_exception(e, self.app.debug)
E 2012-10-03 15:08:29.447 File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
E 2012-10-03 15:08:29.447 return method(*args, **kwargs)
E 2012-10-03 15:08:29.447 File "/base/data/home/apps/s~sigs-enlanube/1.362200469572800834/SIGS.py", line 231, in post
E 2012-10-03 15:08:29.447 descripcion = str(self.request.get('txtDescripcion')).decode('utf-8')
E 2012-10-03 15:08:29.447 UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 2: ordinal not in range(128)

这是stacktrace中提到的行: enter image description here

我正在使用jinja2。这是在文本区域中输入的文本。

enter image description here

这是页面的开始方式: enter image description here

这是文本区域代码:

enter image description here

我不明白为什么我在生产中遇到这个错误,因为在localhost中测试一切都没问题。

提前致谢。

1 个答案:

答案 0 :(得分:1)

可能是由于某个错误,请参阅Encoding problem in app engine when submitting multipart/form-data forms

>>> import quopri
>>> t = unicode(quopri.decodestring('=CD'), 'iso_8859-2')
>>> print t
Í