同事反馈, 有台服务器python无法print中文. 最后查到是因为 LANG设置问题.
系统设置为: LANG="en_US", 修改成: LANG="en_US.utf8" . 问题解决.
操作系统: CentOS 7.x
配置文件 /etc/locale.conf
en_US 与 en_US.utf8 的区别是什么?
$ locale -v -a
locale: en_US archive: /usr/lib/locale/locale-archive
-------------------------------------------------------------------------------
title | English locale for the USA
source | Free Software Foundation, Inc.
address | http://www.gnu.org/software/libc/
email | bug-glibc-locales@gnu.org
language | American English
territory | United States
revision | 1.0
date | 2000-06-24
codeset | ISO-8859-1
locale: en_US.utf8 archive: /usr/lib/locale/locale-archive
-------------------------------------------------------------------------------
title | English locale for the USA
source | Free Software Foundation, Inc.
address | http://www.gnu.org/software/libc/
email | bug-glibc-locales@gnu.org
language | American English
territory | United States
revision | 1.0
date | 2000-06-24
codeset | UTF-8
即, en_US 会使用默认的字符集(codeset) ISO-8859-1, en_US.utf8使用的字符集为UTF-8.