小编典典

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)

flask

我正在使用Flask和Google App Engine构建一个Web应用程序。该Web应用程序中的页面之一通过YouTube API进行调用,以获取带有搜索字词的视频。

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

仅当我通过Jinja2模板将某个参数传递给页面时,才会发生这种情况。

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

阅读 541

收藏
2020-04-06

共1个答案

小编典典

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

import sys
reload(sys)
sys.setdefaultencoding("utf-8")
2020-04-06