UnicodeDecodeError: 'ascii' 编解码器无法解码位置 0 中的字节 0xe5:序号不在范围内 (128) [英] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)

查看:40
本文介绍了UnicodeDecodeError: 'ascii' 编解码器无法解码位置 0 中的字节 0xe5:序号不在范围内 (128)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Flask 和 Google App Engine 构建网络应用程序.此 Web 应用程序中的一个页面通过 YouTube API 进行调用以获取给定搜索词的视频.

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.

当我尝试查询 YoutubeVids.html 时出现以下错误.

I get the following error when I try to query YoutubeVids.html.

这仅在我通过 Jinja2 模板将某个参数传递到页面时发生.

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

推荐答案

想通了.

我将以下内容放在我的python文件的开头

I put the following at the start of my python file

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

这篇关于UnicodeDecodeError: 'ascii' 编解码器无法解码位置 0 中的字节 0xe5:序号不在范围内 (128)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆