⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module-locale.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
📖 第 1 页 / 共 2 页
字号:

<P>
<dl><dt><b><a name='l2h-1495'><tt class='function'>strcoll</tt></a></b> (<var>string1,string2</var>)
<dd>
Compares two strings according to the current <tt class="constant">LC_COLLATE</tt>
setting. As any other compare function, returns a negative, or a
positive value, or <code>0</code>, depending on whether <var>string1</var>
collates before or after <var>string2</var> or is equal to it.
</dl>

<P>
<dl><dt><b><a name='l2h-1496'><tt class='function'>strxfrm</tt></a></b> (<var>string</var>)
<dd>
Transforms a string to one that can be used for the built-in function
<tt class="function">cmp()</tt>, and still returns locale-aware
results.  This function can be used when the same string is compared
repeatedly, e.g. when collating a sequence of strings.
</dl>

<P>
<dl><dt><b><a name='l2h-1497'><tt class='function'>format</tt></a></b> (<var>format, val, </var><big>[</big><var>grouping<code> = 0</code></var><big>]</big>)
<dd>
Formats a number <var>val</var> according to the current
<tt class="constant">LC_NUMERIC</tt> setting.  The format follows the conventions of
the <code>%</code> operator.  For floating point values, the decimal point
is modified if appropriate.  If <var>grouping</var> is true, also takes the
grouping into account.
</dl>

<P>
<dl><dt><b><a name='l2h-1498'><tt class='function'>str</tt></a></b> (<var>float</var>)
<dd>
Formats a floating point number using the same format as the built-in
function <code>str(<var>float</var>)</code>, but takes the decimal point into
account.
</dl>

<P>
<dl><dt><b><a name='l2h-1499'><tt class='function'>atof</tt></a></b> (<var>string</var>)
<dd>
Converts a string to a floating point number, following the
<tt class="constant">LC_NUMERIC</tt> settings.
</dl>

<P>
<dl><dt><b><a name='l2h-1500'><tt class='function'>atoi</tt></a></b> (<var>string</var>)
<dd>
Converts a string to an integer, following the <tt class="constant">LC_NUMERIC</tt>
conventions.
</dl>

<P>
<dl><dt><b><a name='l2h-1501'><tt>LC_CTYPE</tt></a></b>
<dd>

Locale category for the character type functions. Depending on the
settings of this category, the functions of module <tt class='module'><a href="module-string.html" tppabs="http://www.python.org/doc/current/lib/module-string.html">string</a></tt>
dealing with case change their behaviour.
</dl>

<P>
<dl><dt><b><a name='l2h-1502'><tt>LC_COLLATE</tt></a></b>
<dd>
Locale category for sorting strings. The functions
<tt class="function">strcoll()</tt> and <tt class="function">strxfrm()</tt> of the <tt class="module">locale</tt>
module are affected.
</dl>

<P>
<dl><dt><b><a name='l2h-1503'><tt>LC_TIME</tt></a></b>
<dd>
Locale category for the formatting of time. The function
<tt class="function">time.strftime()</tt> follows these conventions.
</dl>

<P>
<dl><dt><b><a name='l2h-1504'><tt>LC_MONETARY</tt></a></b>
<dd>
Locale category for formatting of monetary values. The available
options are available from the <tt class="function">localeconv()</tt> function.
</dl>

<P>
<dl><dt><b><a name='l2h-1505'><tt>LC_MESSAGES</tt></a></b>
<dd>
Locale category for message display. Python currently does not support
application specific locale-aware messages. Messages displayed by the
operating system, like those returned by <tt class="function">os.strerror()</tt>
might be affected by this category.
</dl>

<P>
<dl><dt><b><a name='l2h-1506'><tt>LC_NUMERIC</tt></a></b>
<dd>
Locale category for formatting numbers. The functions
<tt class="function">format()</tt>, <tt class="function">atoi()</tt>, <tt class="function">atof()</tt> and
<tt class="function">str()</tt> of the <tt class="module">locale</tt> module are affected by that
category. All other numeric formatting operations are not affected.
</dl>

<P>
<dl><dt><b><a name='l2h-1507'><tt>LC_ALL</tt></a></b>
<dd>
Combination of all locale settings. If this flag is used when the
locale is changed, setting the locale for all categories is
attempted. If that fails for any category, no category is changed at
all. When the locale is retrieved using this flag, a string indicating
the setting for all categories is returned. This string can be later
used to restore the settings.
</dl>

<P>
<dl><dt><b><a name='l2h-1508'><tt>CHAR_MAX</tt></a></b>
<dd>
This is a symbolic constant used for different values returned by
<tt class="function">localeconv()</tt>.
</dl>

<P>
Example:

<P>
<dl><dd><pre class="verbatim">
&gt;&gt;&gt; import locale
&gt;&gt;&gt; loc = locale.setlocale(locale.LC_ALL) # get current locale
&gt;&gt;&gt; locale.setlocale(locale.LC_ALL, "de") # use German locale
&gt;&gt;&gt; locale.strcoll("f\344n", "foo") # compare a string containing an umlaut 
&gt;&gt;&gt; locale.setlocale(locale.LC_ALL, "") # use user's preferred locale
&gt;&gt;&gt; locale.setlocale(locale.LC_ALL, "C") # use default (C) locale
&gt;&gt;&gt; locale.setlocale(locale.LC_ALL, loc) # restore saved locale
</pre></dl>

<P>

<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL>
<LI><A NAME="tex2html2596"
  HREF="node141.html" tppabs="http://www.python.org/doc/current/lib/node141.html">6.22.1 Background, details, hints, tips and caveats</A>
<LI><A NAME="tex2html2597"
  href="embedding-locale.html" tppabs="http://www.python.org/doc/current/lib/embedding-locale.html">6.22.2 For extension writers and programs that embed Python</A>
</UL>
<!--End of Table of Child-Links-->

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="shutil-example.html" tppabs="http://www.python.org/doc/current/lib/shutil-example.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A HREF="node141.html" tppabs="http://www.python.org/doc/current/lib/node141.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="shutil-example.html" tppabs="http://www.python.org/doc/current/lib/shutil-example.html">6.21.1 Example</A>
<b class="navlabel">Up:</b> <a class="sectref" href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html">6. Generic Operating System</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node141.html" tppabs="http://www.python.org/doc/current/lib/node141.html">6.22.1 Background, details, hints,</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -