本文整理汇总了Python中locale.LC_NUMERIC属性的典型用法代码示例。如果您正苦于以下问题:Python locale.LC_NUMERIC属性的具体用法?Python locale.LC_NUMERIC怎么用?Python locale.LC_NUMERIC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类locale
的用法示例。
在下文中一共展示了locale.LC_NUMERIC属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_comma_decimal_point_locale
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def find_comma_decimal_point_locale():
"""See if platform has a decimal point as comma locale.
Find a locale that uses a comma instead of a period as the
decimal point.
Returns
-------
old_locale: str
Locale when the function was called.
new_locale: {str, None)
First French locale found, None if none found.
"""
if sys.platform == 'win32':
locales = ['FRENCH']
else:
locales = ['fr_FR', 'fr_FR.UTF-8', 'fi_FI', 'fi_FI.UTF-8']
old_locale = locale.getlocale(locale.LC_NUMERIC)
new_locale = None
try:
for loc in locales:
try:
locale.setlocale(locale.LC_NUMERIC, loc)
new_locale = loc
break
except locale.Error:
pass
finally:
locale.setlocale(locale.LC_NUMERIC, locale=old_locale)
return old_locale, new_locale
示例2: setup
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def setup(self):
if self.tst_locale is None:
pytest.skip("No French locale available")
locale.setlocale(locale.LC_NUMERIC, locale=self.tst_locale)
示例3: teardown
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def teardown(self):
locale.setlocale(locale.LC_NUMERIC, locale=self.cur_locale)
示例4: __enter__
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def __enter__(self):
if self.tst_locale is None:
pytest.skip("No French locale available")
locale.setlocale(locale.LC_NUMERIC, locale=self.tst_locale)
示例5: __exit__
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def __exit__(self, type, value, traceback):
locale.setlocale(locale.LC_NUMERIC, locale=self.cur_locale)
示例6: get_enUS_locale
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def get_enUS_locale():
global enUS_locale
if sys.platform == 'darwin':
import os
tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US")
if int(os.uname()[2].split('.')[0]) < 10:
# The locale test work fine on OSX 10.6, I (ronaldoussoren)
# haven't had time yet to verify if tests work on OSX 10.5
# (10.4 is known to be bad)
raise unittest.SkipTest("Locale support on MacOSX is minimal")
if sys.platform.startswith("win"):
tlocs = ("En", "English")
else:
tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US")
oldlocale = locale.setlocale(locale.LC_NUMERIC)
for tloc in tlocs:
try:
locale.setlocale(locale.LC_NUMERIC, tloc)
except locale.Error:
continue
break
else:
raise unittest.SkipTest(
"Test locale not supported (tried %s)" % (', '.join(tlocs)))
enUS_locale = tloc
locale.setlocale(locale.LC_NUMERIC, oldlocale)
示例7: test_setlocale_category
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def test_setlocale_category(self):
locale.setlocale(locale.LC_ALL)
locale.setlocale(locale.LC_TIME)
locale.setlocale(locale.LC_CTYPE)
locale.setlocale(locale.LC_COLLATE)
locale.setlocale(locale.LC_MONETARY)
locale.setlocale(locale.LC_NUMERIC)
# crasher from bug #7419
self.assertRaises(locale.Error, locale.setlocale, 12345)
示例8: setup
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def setup(self):
if self.tst_locale is None:
raise SkipTest("No French locale available")
locale.setlocale(locale.LC_NUMERIC, locale=self.tst_locale)
示例9: __enter__
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def __enter__(self):
if self.tst_locale is None:
raise SkipTest("No French locale available")
locale.setlocale(locale.LC_NUMERIC, locale=self.tst_locale)
示例10: setUpClass
# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_NUMERIC [as 别名]
def setUpClass(cls):
if sys.platform == 'darwin':
import os
tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US")
if int(os.uname().release.split('.')[0]) < 10:
# The locale test work fine on OSX 10.6, I (ronaldoussoren)
# haven't had time yet to verify if tests work on OSX 10.5
# (10.4 is known to be bad)
raise unittest.SkipTest("Locale support on MacOSX is minimal")
elif sys.platform.startswith("win"):
tlocs = ("En", "English")
else:
tlocs = ("en_US.UTF-8", "en_US.ISO8859-1",
"en_US.US-ASCII", "en_US")
try:
oldlocale = locale.setlocale(locale.LC_NUMERIC)
for tloc in tlocs:
try:
locale.setlocale(locale.LC_NUMERIC, tloc)
except locale.Error:
continue
break
else:
raise unittest.SkipTest("Test locale not supported "
"(tried %s)" % (', '.join(tlocs)))
cls.enUS_locale = tloc
finally:
locale.setlocale(locale.LC_NUMERIC, oldlocale)