UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

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)

上一篇:@requestbody泛型映射@JsonTypeInfo多态


下一篇:lyt经典版MySQL基础——进阶5:分组查询