python 获取本地语言和编码的代码
#! /usr/bin/env python # encoding=utf8 import locale language, encoding = locale.getdefaultlocale() print("language", language) print("encoding", encoding)
输出:
language zh_CN encoding cp936
#! /usr/bin/env python # encoding=utf8 import locale language, encoding = locale.getdefaultlocale() print("language", language) print("encoding", encoding)
输出:
language zh_CN encoding cp936