为什么我在生产中却没有在开发中遇到这种Unicodeer错误?应用程序引擎Python

为什么我在生产中却没有在开发中遇到这种Unicodeer错误?应用程序引擎Python,python,google-app-engine,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

我知道这个问题以前已经被问过很多次了,我可能应该在这个问题上投反对票 但我做了很多尝试,但都没有成功

我的申请正在生产中

我得到了这个错误:

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中提到的行:

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

页面是这样开始的:

这是文本区号:

我不明白为什么在生产中会出现这个错误,因为在localhost中测试时,一切都正常


提前感谢。

这可能是由于一个错误,请参阅


你的HTML页面是UTF-8编码的吗?为什么需要str()?为什么你要在str()之后解码,而不是在get之后解码?@voscausa我应该如何正确地进行解码?这样:解码(self.request.get('stuff'),utf-8)?这里有一篇好文章:。我想你必须编码:descripion=self.request.get('txtdescription')。解码('utf-8')。试试这个:@robertking谢谢罗伯特。显然,它与多部分/表单数据表单有关。我稍后会尝试一些建议。
>>> import quopri
>>> t = unicode(quopri.decodestring('=CD'), 'iso_8859-2')
>>> print t
Í