ubuntu 16
python3.6
print(‘中文‘)
UnicodeEncodeError: ‘ascii‘ codec can‘t encode characters in position 0-1: ordinal not in range(128)
首先
import sys
print(sys.stdout.encoding)
ANSI_X3.4-1968
只需要在终端:export LC_ALL=C.UTF-8
再次查看
import sys
print(sys.stdout.encoding)
UTF-8
那么现在
print(‘中文‘)
中文
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)