美文网首页
python运行提示编码不正确

python运行提示编码不正确

作者: 八戒只有一个 | 来源:发表于2019-09-29 11:32 被阅读0次

如果遇到python运行时提示编码格式不正确,错误代码为:'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)

则在页面头部粘贴下列内容,亲测可行!

#! /usr/bin/env python

# -*- coding: utf-8 -*- importsys

#要重新载入sys。因为 Python 初始化后会删除 sys.setdefaultencoding 这个方法

reload(sys)sys.setdefaultencoding('utf-8')

相关文章

网友评论

      本文标题:python运行提示编码不正确

      本文链接:https://www.haomeiwen.com/subject/cikfpctx.html