本文整理匯總了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)