UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-2: ordinal not in range(128)

linux终端出现UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-2: ordinal not in range(128) 中文乱码报错的解决方案

解决:

(1)设置环境变量LANG
修改~/.profile文件,执行:

export LANG=“en_US.UTF-8>> ~/.profile
source ~/.bash_profile

(2)给python执行命令添加utf-8 ,执行:

export PYTHONIOENCODING=utf-8 >> ~/.bashrc
source ~/.bashrc

转载:https://www.cnblogs.com/beile/p/12980149.html