---
title: "Python 国际化"
author: "mcgtts"
date: "2011-09-18T11:14:06Z"
tags: []
categories: ["编程语言"]
slug: "python"
draft: false
lastmod: "2011-09-18T11:14:06Z"
id: 1174445
url: "https://mcgtts.iteye.com/blog/1174445"
---

```
>>> help(locale)
Help on module locale:

NAME
    locale - Locale support.

FILE
    c:\python27\lib\locale.py

DESCRIPTION
    The module provides low-level access to the C lib's locale APIs
    and adds high level number formatting APIs as well as a locale
    aliasing engine to complement these.
    
    The aliasing engine includes support for many commonly used locale
    names and maps them to values suitable for passing to the C lib's
    setlocale() function. It also includes default encodings for all
    supported locale names.

>>> import locale
>>> locale.setlocale(locale.LC_ALL, "")
"Chinese (Simplified)_People's Republic of China.936"

>>> lang, encoding = locale.getdefaultlocale()
>>> print lang
zh_CN
>>> print encoding
cp936
>>> 
```