问题描述:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-12: ordinal not in range(128)
解决方法:
1、运行程序时加上 PYTHONIOENCODING,如下
PYTHONIOENCODING=utf-8 python app_run.py &
PYTHONIOENCODING=utf-8 python app_run.py >> log.log 2>&1 &
2、重新定义输出标准
import codecs
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
sys.stdout.write("Your content....")