没有项目描述

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_pointThe decimal point character, except for currency values, cannot be an empty string.
thousands_sepThe separator between groups of digits before the decimal point, except for currency values.
groupingThe 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_symbolThe standardized international currency symbol.
currency_symbolThe local currency symbol.
mon_decimal_pointThe decimal point character for currency values.
mon_thousands_sepThe separator for digit groups in currency values.
mon_groupingLike grouping but for currency values.
positive_signThe character used to denote nonnegative currency values, usually the empty string.
negative_signThe character used to denote negative currency values, usually a minus sign.
int_frac_digitsThe number of digits after the decimal point in an international-style currency value.
frac_digitsThe number of digits after the decimal point in the locale style for currency values.
p_cs_precedesTrue if the currency symbol precedes the currency value for nonnegative values, False if it follows.
p_sep_by_spaceTrue if a space is inserted between the currency symbol and the currency value for nonnegative values, False otherwise.
n_cs_precedesLike p_cs_precedes but for negative values.
n_sep_by_spaceLike 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:

  • 0 - Parentheses around the entire string.
  • 1 - Before the string.
  • 2 - After the string.
  • 3 - Just before currency_symbol.
  • 4 - Just after currency_symbol.
n_sign_posnLike p_sign_posn but for negative currency values.
int_p_cs_precedesSame as p_cs_precedes, but for internationally monetary quantities. formatted monetary quantities.
int_n_cs_precedesSame as n_cs_precedes, but for internationally monetary quantities. formatted monetary quantities.
int_p_sep_by_spaceSame as p_sep_by_space, but for internationally formatted monetary quantities.
int_n_sep_by_spaceSame as n_sep_by_space, but for internationally formatted monetary quantities.
int_p_sign_posnSame as p_sign_posn, but for internationally formatted monetary quantities.
int_n_sign_posnSame as n_sign_posn, but for internationally formatted monetary quantities.

常数

ConstantDescription
^{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日

  • 首次发布

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用Spring和JSF向客户端授予临时权限   java除了Array/ArrayList之外,还有其他保存矩阵元素的方法吗   java BeanValidation不适用于单选按钮   通过java程序连接到配置单元数据库时出错   java如何使用maven解决二级依赖关系   JfreeChart/Java中带有图例的数据表   合并数组时发生java运行时错误   安全性如何在JavaEE中保护WebSocket端点?   java有没有一种方法可以使用insert方法为树插入值   java编程“静态”的另一种方式:代码可以吗?   java阅读文本文件时如何跳过3行   %04X在C中的含义以及如何在java中编写   java我如何验证一个方法不是仅在一个测试范围内对模拟调用的?   java如何在mac中使用启动appium desktop 1.6.1。球棒   仅匹配最多10位小数的java正则表达式