Skip to content

Instantly share code, notes, and snippets.

@aweffr
Last active April 10, 2019 09:12
Show Gist options
  • Save aweffr/fd0da666308aaf7d1575f581f7b48b50 to your computer and use it in GitHub Desktop.
Save aweffr/fd0da666308aaf7d1575f581f7b48b50 to your computer and use it in GitHub Desktop.
修复中文的locale在CentOS中的问题
#!/usr/bin/env python
# encoding=utf-8
import os
new_lines = []
with open("/etc/yum.conf", "r") as f:
for line in f:
line = line.strip()
new_lines.append(
line.replace("override_install_langs=en_US.UTF-8", "")
)
with open("/etc/yum.conf", "w") as f:
f.writelines("\n".join(new_lines))
os.system("yum -y -q reinstall glibc-common")
os.system("locale -a | grep zh")
with open("/root/.bashrc", "a") as f:
f.write("export LANG=zh_CN.utf8\n")
f.write("export LC_ALL=zh_CN.utf8\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment