UNI codeDE codeError:“ASCII”codeC可以在0位置没有去code字节为0xE5:序数不在范围内(128) [英] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)
本文介绍了UNI codeDE codeError:“ASCII”codeC可以在0位置没有去code字节为0xE5:序数不在范围内(128)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我建立使用瓶和谷歌App Engine的Web应用程序。人在这个Web应用程序的页面允许用户通过YouTube的API调用来获得视频给出一个搜索词。
我收到以下错误,当我尝试查询 YoutubeVids.html
。
当我通过Jinja2的模板页面通过一定的参数,这只是发生。
文件/Users/xxxxx/App-Engine/src/templates/YoutubeVids.html,1号线,在顶级模板code
{%伸出master.html%}
UNI codeDE codeError:ASCIIcodeC可以在0位置没有去code字节为0xE5:序数不在范围内(128)INFO 2014年1月27日22:39:40963 module.py:612]默认:GET / XXX / YYYY HTTP / 1.1500 291
解决方案
想通了。
我把我的蟒蛇文件的开头
以下 进口SYS
重装(SYS)
sys.setdefaultencoding函数(UTF-8)
I am building a web application using Flask and Google App Engine. One of the pages in this web application makes a call via YouTube APIs to get videos given a search term.
I get the following error when I try to query YoutubeVids.html
.
This only happens when when I pass a certain parameter via Jinja2 templates to the page.
file "/Users/xxxxx/App-Engine/src/templates/YoutubeVids.html", line 1, in top-level template code
{% extends "master.html" %}
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)
INFO 2014-01-27 22:39:40,963 module.py:612] default: "GET /xxx/yyyy HTTP/1.1" 500 291
解决方案
Figured it out.
I put the following at the start of my python file
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
这篇关于UNI codeDE codeError:“ASCII”codeC可以在0位置没有去code字节为0xE5:序数不在范围内(128)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文