Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit968d51b

Browse files
[3.14]gh-85204: Improvelocale.setlocale example (GH-132683) (#142798)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent8150abb commit968d51b

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

‎Doc/library/locale.rst‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,19 @@ The :mod:`locale` module defines the following exception and functions:
4848
If *locale* is omitted or ``None``, the current setting for *category* is
4949
returned.
5050

51+
Example::
52+
53+
>>> import locale
54+
>>> loc = locale.setlocale(locale.LC_ALL) # get current locale
55+
# use German locale; name and availability varies with platform
56+
>>> locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
57+
>>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut
58+
>>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
59+
>>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale
60+
>>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale
61+
5162
:func:`setlocale` is not thread-safe on most systems. Applications typically
52-
start with a call of::
63+
start with a call of::
5364

5465
import locale
5566
locale.setlocale(locale.LC_ALL, '')
@@ -573,18 +584,6 @@ The :mod:`locale` module defines the following exception and functions:
573584
:func:`localeconv`.
574585

575586

576-
Example::
577-
578-
>>> import locale
579-
>>> loc = locale.getlocale() # get current locale
580-
# use German locale; name might vary with platform
581-
>>> locale.setlocale(locale.LC_ALL, 'de_DE')
582-
>>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut
583-
>>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
584-
>>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale
585-
>>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale
586-
587-
588587
Background, details, hints, tips and caveats
589588
--------------------------------------------
590589

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp