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

📄 built-in-funcs.html

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

<P>
<dl><dt><b><a name='l2h-171'><tt class='function'>len</tt></a></b> (<var>s</var>)
<dd>
  Return the length (the number of items) of an object.  The argument
  may be a sequence (string, tuple or list) or a mapping (dictionary).
</dl>

<P>
<dl><dt><b><a name='l2h-172'><tt class='function'>list</tt></a></b> (<var>sequence</var>)
<dd>
Return a list whose items are the same and in the same order as
<var>sequence</var>'s items.  If <var>sequence</var> is already a list,
a copy is made and returned, similar to <code><var>sequence</var>[:]</code>.  
For instance, <code>list('abc')</code> returns
returns <code>['a', 'b', 'c']</code> and <code>list( (1, 2, 3) )</code> returns
<code>[1, 2, 3]</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-173'><tt class='function'>locals</tt></a></b> ()
<dd>
Return a dictionary representing the current local symbol table.
<b>Warning:</b> The contents of this dictionary should not be
modified; changes may not affect the values of local variables used by 
the interpreter.
</dl>

<P>
<dl><dt><b><a name='l2h-174'><tt class='function'>long</tt></a></b> (<var>x</var>)
<dd>
  Convert a string or number to a long integer.  If the argument is a
  string, it must contain a possibly signed decimal number of
  arbitrary size, possibly embedded in whitespace;
  this behaves identical to <code>string.atol(<var>x</var>)</code>.
  Otherwise, the argument may be a plain or
  long integer or a floating point number, and a long integer with
  the same value is returned.    Conversion of floating
  point numbers to integers is defined by the C semantics;
  see the description of <tt class="function">int()</tt>.
</dl>

<P>
<dl><dt><b><a name='l2h-175'><tt class='function'>map</tt></a></b> (<var>function, list, ...</var>)
<dd>
Apply <var>function</var> to every item of <var>list</var> and return a list
of the results.  If additional <var>list</var> arguments are passed, 
<var>function</var> must take that many arguments and is applied to
the items of all lists in parallel; if a list is shorter than another
it is assumed to be extended with <code>None</code> items.  If
<var>function</var> is <code>None</code>, the identity function is assumed; if
there are multiple list arguments, <tt class="function">map()</tt> returns a list
consisting of tuples containing the corresponding items from all lists
(i.e. a kind of transpose operation).  The <var>list</var> arguments may be
any kind of sequence; the result is always a list.
</dl>

<P>
<dl><dt><b><a name='l2h-176'><tt class='function'>max</tt></a></b> (<var>s</var><big>[</big><var>, args...</var><big>]</big>)
<dd>
With a single argument <var>s</var>, return the largest item of a
non-empty sequence (e.g., a string, tuple or list).  With more than
one argument, return the largest of the arguments.
</dl>

<P>
<dl><dt><b><a name='l2h-177'><tt class='function'>min</tt></a></b> (<var>s</var><big>[</big><var>, args...</var><big>]</big>)
<dd>
With a single argument <var>s</var>, return the smallest item of a
non-empty sequence (e.g., a string, tuple or list).  With more than
one argument, return the smallest of the arguments.
</dl>

<P>
<dl><dt><b><a name='l2h-178'><tt class='function'>oct</tt></a></b> (<var>x</var>)
<dd>
  Convert an integer number (of any size) to an octal string.  The
  result is a valid Python expression.  Note: this always yields
  an unsigned literal, e.g. on a 32-bit machine, <code>oct(-1)</code> yields
  <code>'037777777777'</code>.  When evaluated on a machine with the same
  word size, this literal is evaluated as -1; at a different word
  size, it may turn up as a large positive number or raise an
  <tt class="exception">OverflowError</tt> exception.
</dl>

<P>
<dl><dt><b><a name='l2h-179'><tt class='function'>open</tt></a></b> (<var>filename</var><big>[</big><var>, mode</var><big>[</big><var>, bufsize</var><big>]</big><big>]</big>)
<dd>
  Return a new file object (described earlier under Built-in Types).
  The first two arguments are the same as for <code>stdio</code>'s
  <tt class="cfunction">fopen()</tt>: <var>filename</var> is the file name to be opened,
  <var>mode</var> indicates how the file is to be opened: <code>'r'</code> for
  reading, <code>'w'</code> for writing (truncating an existing file), and
  <code>'a'</code> opens it for appending (which on <i>some</i> Unix
  systems means that <i>all</i> writes append to the end of the file,
  regardless of the current seek position).

<P>
Modes <code>'r+'</code>, <code>'w+'</code> and <code>'a+'</code> open the file for
  updating (note that <code>'w+'</code> truncates the file).  Append
  <code>'b'</code> to the mode to open the file in binary mode, on systems
  that differentiate between binary and text files (else it is
  ignored).  If the file cannot be opened, <tt class="exception">IOError</tt> is
  raised.

<P>
If <var>mode</var> is omitted, it defaults to <code>'r'</code>.  When opening a 
  binary file, you should append <code>'b'</code> to the <var>mode</var> value
  for improved portability.  (It's useful even on systems which don't
  treat binary and text files differently, where it serves as
  documentation.)
  
  The optional <var>bufsize</var> argument specifies the
  file's desired buffer size: 0 means unbuffered, 1 means line
  buffered, any other positive value means use a buffer of
  (approximately) that size.  A negative <var>bufsize</var> means to use
  the system default, which is usually line buffered for for tty
  devices and fully buffered for other files.  If omitted, the system
  default is used.<A NAME="tex2html10"
  HREF="#foot2998"><SUP>2.10</SUP></A></dl>

<P>
<dl><dt><b><a name='l2h-180'><tt class='function'>ord</tt></a></b> (<var>c</var>)
<dd>
  Return the ASCII value of a string of one character or a Unicode
  character.  E.g., <code>ord('a')</code> returns the integer <code>97</code>,
  <code>ord(u'
<BR>
u2020')</code> returns <code>8224</code>.  This is the inverse of
  <tt class="function">chr()</tt> for strings and of <tt class="function">unichr()</tt> for Unicode
  characters.
</dl>

<P>
<dl><dt><b><a name='l2h-181'><tt class='function'>pow</tt></a></b> (<var>x, y</var><big>[</big><var>, z</var><big>]</big>)
<dd>
  Return <var>x</var> to the power <var>y</var>; if <var>z</var> is present, return
  <var>x</var> to the power <var>y</var>, modulo <var>z</var> (computed more
  efficiently than <code>pow(<var>x</var>, <var>y</var>) % <var>z</var></code>).
  The arguments must have
  numeric types.  With mixed operand types, the rules for binary
  arithmetic operators apply.  The effective operand type is also the
  type of the result; if the result is not expressible in this type, the
  function raises an exception; e.g., <code>pow(2, -1)</code> or <code>pow(2,
  35000)</code> is not allowed.
</dl>

<P>
<dl><dt><b><a name='l2h-182'><tt class='function'>range</tt></a></b> (<big>[</big><var>start,</var><big>]</big><var> stop</var><big>[</big><var>, step</var><big>]</big>)
<dd>
  This is a versatile function to create lists containing arithmetic
  progressions.  It is most often used in <tt class="keyword">for</tt> loops.  The
  arguments must be plain integers.  If the <var>step</var> argument is
  omitted, it defaults to <code>1</code>.  If the <var>start</var> argument is
  omitted, it defaults to <code>0</code>.  The full form returns a list of
  plain integers <code>[<var>start</var>, <var>start</var> + <var>step</var>,
  <var>start</var> + 2 * <var>step</var>, ...]</code>.  If <var>step</var> is positive,
  the last element is the largest <code><var>start</var> + <var>i</var> *
  <var>step</var></code> less than <var>stop</var>; if <var>step</var> is negative, the last
  element is the largest <code><var>start</var> + <var>i</var> * <var>step</var></code>
  greater than <var>stop</var>.  <var>step</var> must not be zero (or else
  <tt class="exception">ValueError</tt> is raised).  Example:

<P>
<dl><dd><pre class="verbatim">
&gt;&gt;&gt; range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
&gt;&gt;&gt; range(1, 11)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
&gt;&gt;&gt; range(0, 30, 5)
[0, 5, 10, 15, 20, 25]
&gt;&gt;&gt; range(0, 10, 3)
[0, 3, 6, 9]
&gt;&gt;&gt; range(0, -10, -1)
[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
&gt;&gt;&gt; range(0)
[]
&gt;&gt;&gt; range(1, 0)
[]
</pre></dl>
</dl>

<P>
<dl><dt><b><a name='l2h-183'><tt class='function'>raw_input</tt></a></b> (<big>[</big><var>prompt</var><big>]</big>)
<dd>
  If the <var>prompt</var> argument is present, it is written to standard output
  without a trailing newline.  The function then reads a line from input,
  converts it to a string (stripping a trailing newline), and returns that.
  When EOF is read, <tt class="exception">EOFError</tt> is raised. Example:

<P>
<dl><dd><pre class="verbatim">
&gt;&gt;&gt; s = raw_input('--&gt; ')
--&gt; Monty Python's Flying Circus
&gt;&gt;&gt; s
"Monty Python's Flying Circus"
</pre></dl>

<P>
If the <tt class="module">readline</tt> module was loaded, then
<tt class="function">raw_input()</tt> will use it to provide elaborate
line editing and history features.
</dl>

<P>
<dl><dt><b><a name='l2h-184'><tt class='function'>reduce</tt></a></b> (<var>function, sequence</var><big>[</big><var>, initializer</var><big>]</big>)
<dd>
Apply <var>function</var> of two arguments cumulatively to the items of
<var>sequence</var>, from left to right, so as to reduce the sequence to
a single value.  For example,
<code>reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])</code> calculates
<code>((((1+2)+3)+4)+5)</code>.
If the optional <var>initializer</var> is present, it is placed before the
items of the sequence in the calculation, and serves as a default when
the sequence is empty.
</dl>

<P>
<dl><dt><b><a name='l2h-185'><tt class='function'>reload</tt></a></b> (<var>module</var>)
<dd>
Re-parse and re-initialize an already imported <var>module</var>.  The
argument must be a module object, so it must have been successfully
imported before.  This is useful if you have edited the module source
file using an external editor and want to try out the new version
without leaving the Python interpreter.  The return value is the
module object (i.e. the same as the <var>module</var> argument).

<P>
There are a number of caveats:

<P>
If a module is syntactically correct but its initialization fails, the
first <tt class="keyword">import</tt> statement for it does not bind its name locally,
but does store a (partially initialized) module object in
<code>sys.modules</code>.  To reload the module you must first
<tt class="keyword">import</tt> it again (this will bind the name to the partially
initialized module object) before you can <tt class="function">reload()</tt> it.

<P>

⌨️ 快捷键说明

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