您的位置:首页 > 编程语言 > Python开发

python flask 加载html运行错误

2016-11-23 14:22 337 查看
python flask 加载html运行错误



'utf8' codec can't decode byte 0xbb in

解决方法是 .py 文件不是utf8格式的文件导致

Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

[2016-11-23 11:51:51,020] ERROR in app: Exception on / [GET]

Traceback (most recent call last):

  File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1988, in wsgi_app

    response = self.full_dispatch_request()

  File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1641, in full_dispatch_request

    rv = self.handle_user_exception(e)

  File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1544, in handle_user_exception

    reraise(exc_type, exc_value, tb)

  File "/usr/local/lib/python3.4/dist-packages/flask/_compat.py", line 33, in reraise

    raise value

  File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1639, in full_dispatch_request

    rv = self.dispatch_request()

  File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1625, in dispatch_request

    return self.view_functions[rule.endpoint](**req.view_args)

  File "app.py", line 7, in home

    return render_template('1.html')

  File "/usr/local/lib/python3.4/dist-packages/flask/templating.py", line 133, in render_template

    return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),

  File "/usr/local/lib/python3.4/dist-packages/jinja2/environment.py", line 851, in get_or_select_template

    return self.get_template(template_name_or_list, parent, globals)

  File "/usr/local/lib/python3.4/dist-packages/jinja2/environment.py", line 812, in get_template

    return self._load_template(name, self.make_globals(globals))

  File "/usr/local/lib/python3.4/dist-packages/jinja2/environment.py", line 774, in _load_template

    cache_key = self.loader.get_source(self, name)[1]

  File "/usr/local/lib/python3.4/dist-packages/flask/templating.py", line 57, in get_source

    return self._get_source_fast(environment, template)

  File "/usr/local/lib/python3.4/dist-packages/flask/templating.py", line 82, in _get_source_fast

    return loader.get_source(environment, template)

  File "/usr/local/lib/python3.4/dist-packages/jinja2/loaders.py", line 175, in get_source

    contents = f.read().decode(self.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 613: invalid start byte

127.0.0.1 - - [23/Nov/2016 11:51:51] "GET / HTTP/1.1" 500 -
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python cant decode byte