没有项目描述
xlocale的Python项目详细描述
这个包向python公开了xlocale系列c函数的一部分。这个 对于设置每个线程的区域设置特别有用。
通常使用locale.setlocale 用于更改整个过程的区域设置的函数:
import locale locale.setlocale(locale.LC_ALL, 'nl_NL')
这对于使用 多线程。只更改当前线程的区域设置 执行以下操作:
import xlocale loc = xlocale.Locale(xlocale.LC_ALL_MASK, 'nl_NL') loc.use()
创建语言环境对象
- xlocale.locale([mask[,locale[,base]])
创建新的语言环境对象。新的区域设置由take创建 基本区域设置并更改一个或多个区域设置类别。如果 没有给定基,将使用C语言环境。
mask是从LC_*_MASK常量生成的位掩码。通常你 将要使用LC_ALL_MASK来完全更改区域设置。
locale是具有区域设置名称的字符串。如果没有提供c语言环境 将被使用。
- xlocale.locale.current_locale()
- 返回当前区域设置的区域设置实例。
区域设置实例
- locale.use()
- 切换当前线程的区域设置。
- locale.name(掩码)
返回区域设置类别的名称。mask是区域设置的位掩码 类别,将返回第一个配置的类别的名称。
此方法在所有平台上都不可用,将引发异常 在不受支持的平台上。
- locale.lconv()
- 返回描述数字和货币值必须如何 以当前区域设置显示。这是一个具有以下内容的对象 属性:
decimal_point | The decimal point character, except for currency values, cannot be an empty string. |
thousands_sep | The separator between groups of digits before the decimal point, except for currency values. |
grouping | The sizes of the groups of digits, except for currency This is a list of integers representing group size from low order digit groups to high order (right to left). The list may be terminated with 0 or CHAR_MAX. If the list is terminated with 0 the last group size before the 0 is repeated to account for all the digits. If the list isterminated with CHAR_MAX, no more grouping is performed. |
int_curr_symbol | The standardized international currency symbol. |
currency_symbol | The local currency symbol. |
mon_decimal_point | The decimal point character for currency values. |
mon_thousands_sep | The separator for digit groups in currency values. |
mon_grouping | Like grouping but for currency values. |
positive_sign | The character used to denote nonnegative currency values, usually the empty string. |
negative_sign | The character used to denote negative currency values, usually a minus sign. |
int_frac_digits | The number of digits after the decimal point in an international-style currency value. |
frac_digits | The number of digits after the decimal point in the locale style for currency values. |
p_cs_precedes | True if the currency symbol precedes the currency value for nonnegative values, False if it follows. |
p_sep_by_space | True if a space is inserted between the currency symbol and the currency value for nonnegative values, False otherwise. |
n_cs_precedes | Like p_cs_precedes but for negative values. |
n_sep_by_space | Like p_sep_by_space but for negative values. |
p_sign_posn | The location of the positive_sign with respect to a nonnegative quantity and the currency_symbol, coded as follows:
|
n_sign_posn | Like p_sign_posn but for negative currency values. |
int_p_cs_precedes | Same as p_cs_precedes, but for internationally monetary quantities. formatted monetary quantities. |
int_n_cs_precedes | Same as n_cs_precedes, but for internationally monetary quantities. formatted monetary quantities. |
int_p_sep_by_space | Same as p_sep_by_space, but for internationally formatted monetary quantities. |
int_n_sep_by_space | Same as n_sep_by_space, but for internationally formatted monetary quantities. |
int_p_sign_posn | Same as p_sign_posn, but for internationally formatted monetary quantities. |
int_n_sign_posn | Same as n_sign_posn, but for internationally formatted monetary quantities. |
常数
Constant | Description |
---|---|
^{tt6}$ | Collation |
^{tt7}$ | Character type |
^{tt8}$ | Messages |
^{tt9}$ | Monetary |
^{tt10}$ | Numeric |
^{tt11}$ | Time |
^{tt3}$ | Combination of all of the above. |
更改日志
1.3.4-2018年2月25日
- 更多的python 3编译修复。
1.3.3-2018年2月25日
- python 3没有pyint。
1.3.2-2018年2月25日
- 修复在创建区域设置时引发的异常的处理:它们现在是 正确地被看作是在构造函数中引发的。
1.3.1-2018年2月23日
- 添加Python3支持。
- 添加manylinux支持。
1.2-2014年11月15日
- 不再从locale.use()返回当前区域设置。这创造了 不可解的双自由问题。
1.1-2014年10月10日
- 修复locale.use()中可能导致segfault的内存处理错误 多次使用区域设置实例时。
1.0-2014年8月27日
- 首次发布