如果遇到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')