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

📄 263.html

📁 Python Ebook Python&XML
💻 HTML
📖 第 1 页 / 共 3 页
字号:

				
				<h4>Number Protocol</h4><pre>
						
int PyNumber_Check(PyObject *o)

					</pre>

					<p>Returns <tt class="monofont">1</tt> if the object <tt ClaSs="monofont">o</tt> provides numeric protocols, and <Tt claSs="monofont">false</tt> otherwise. This function always succeeds.<A NAMe="idx1073751008"></a><a nAME="idx1073751009"></A><a namE="idx1073751010"></A><A Name="idx1073751011"></a><A NAMe="idx1073751012"></a><a name="idx1073751013"></a><a name="idx1073751014"></a><a name="idx1073751015"></a><A naMe="idx1073751016"></a><a Name="idx1073751017"></a><A namE="idx1073751018"></A></P>

					<Pre>
						
PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)

					</prE>

					<P>Return value: New reference. Returns the result of adding <TT clasS="monofont">o1</TT> and <Tt claSS="monofont">o2,</TT> or <tt class="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <tt class="monofont">"o1 + o2".</tt></p>

					<pRe>
						
PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2)

					</pRe>

					<p>Return value: New reference. Returns the result of subtracting <tT clasS="monofont">o2</tt> from <tT CLAss="monofont">o1,</tt> or <TT CLass="monofont">NULL</tT> on failure. This is the equivalent of the Python expression <TT Class="monofont">"o1 - o2".</TT></P>

					<Pre>
						
PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2)

					</pre>

					<p>Return value: New reference. Returns the result of multiplying <tt class="monofont">o1</tt> and <tt claSs="monofont">o2,</tT> or <tt cLass="monofont">NULL</tT> on failure. This is the equivalent of the Python expression <tt cLASS="monofont">"o1 * o2".</tt></p>

					<pRE>
						
PyObject* PyNumber_Divide(PyObject *o1, PyObject *o2)

					</PRe>

					<p>Return value: New reference. Returns the result of dividing <tt CLASs="monofont">o1</tt> by <tT CLAss="monofont">o2,</tt> or <tt class="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <tt class="monofont">"o1 / o2".</Tt></p>

					<Pre>
						
PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)

					</pRe>

					<p>Return value: New reference. Returns the remainder of dividing <tt ClasS="monofont">o1</TT> by <Tt claSS="monofont">o2,</TT> or <tt clASS="monofont">NULL</Tt> on failure. This is the equivalent of the Python expression <tt cLASS="monofont">"o1 % o2".</tt></p>

					<pre>
						
PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)

					</pre>

					<p>Return value: New reference. See the built-in function <tt class="monofont">divmod().</tt> Returns <tT clAss="monofont">NULL</tT> on failure. This is the equivalent of the Python expression <tt clAss="monofont">"divmod(o1, o2)".</tT></P>

					<PRe>
						
PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)

					</pre>

					<P>Return value: New reference. See the built-in function <TT Class="monofont">pow().</TT> Returns <TT clasS="monofont">NULL</TT> on failure. This is the equivalent of the Python expression <Tt class="monofont">"pow(o1, o2, o3)",</tt> where <tt class="monofont">o3</tt> is optional. If <tt cLasS="monofont">o3</tt> is to be ignored, pass <tT clasS="monofont">Py_None</tt> in its place (passing <tT CLAss="monofont">NULL</tt> for <TT CLass="monofont">o3</tT> would cause an illegal memory access).</P>

					<PRe>
						
PyObject* PyNumber_Negative(PyObject *o)

					</pre>

					<P>Return value: New reference. Returns the negation of <TT Class="monofont">o</tt> on success, or <tt class="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <tt claSs="monofont">"-o"</tT><a naMe="idx1073751019"></a><a nAme="idx1073751020"></a><A NAMe="idx1073751021"></a><a nAME="idx1073751022"></A><a namE="idx1073751023"></A><A Name="idx1073751024"></a><A NAMe="idx1073751025"></a><a name="idx1073751026"></a><a name="idx1073751027"></a><a name="idx1073751028"></a><A naMe="idx1073751029"></a></p>

					<Pre>
						
PyObject* PyNumber_Positive(PyObject *o)

					</prE>

					<p>Return value: New reference. Returns <tt CLASs="monofont">o</tt> on success, or <tT CLAss="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <TT CLass="monofont">"+o".</tT></P>

					<PRe>
						
PyObject* PyNumber_Absolute(PyObject *o)

					</pre>

					<p>Return value: New reference. Returns the absolute value of <tt class="monofont">o,</tt> or <tt clasS="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <Tt clAss="monofont">"abs(o)".</tt></P>

					<pre>
						
PyObject* PyNumber_Invert(PyObject *o)

					</PRE>

					<P>Return value: New reference. Returns the bitwise negation of <tt clASS="monofont">o</Tt> on success, or <tt cLASS="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <tt CLASs="monofont">"~o".</tt></p>

					<pre>
						
PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2)

					</pre>

					<p>Return value: New reference. Returns the result of left shifting <tt class="monofont">o1</tt> by <Tt cLass="monofont">o2</Tt> on success, or <tt cLass="monofont">NULL</TT> on failure. This is the equivalent of the Python expression <TT clasS="monofont">"o1 &lt;&lt; o2".</TT></P>

					<pre>
						
PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2)

					</pRE>

					<P>Return value: New reference. Returns the result of right shifting <Tt claSS="monofont">o1</TT> by <tt class="monofont">o2</tt> on success, or <tt class="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <tt ClaSs="monofont">"o1 &gt;&gt; o2".</tt></P>

					<pre>
						
PyObject* PyNumber_And(PyObject *o1, PyObject *o2)

					</pRe>

					<p>Return value: New reference. Returns the result of "anding"
						<tT CLAss="monofont">o1</tt> and <TT CLass="monofont">o2</tT> on success and <TT Class="monofont">NULL</TT> on failure. This is the equivalent of the Python expression <TT class="monofont">"o1 and o2".</tt></p>

					<pre>
						
PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2)

					</pre>

					<p>Return value: New reference. Returns the bitwise exclusive <tt claSs="monofont">or</tT> of <tt cLass="monofont">o1</tT> by <tt cLASS="monofont">o2</tt> on success, or <tt CLASs="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <tT CLAss="monofont">"o1 ^ o2".</tt></P>

					<PRE>
						
PyObject* PyNumber_Or(PyObject *o1, PyObject *o2)

					</pre>

					<p>Return value: New reference. Returns the result of <tt class="monofont">o1</tt> and <tt class="monofont">o2</Tt> on success, or <tT claSs="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <tT claSS="monofont">"o1 or o2".</TT><a namE="idx1073751030"></A><A Name="idx1073751031"></a><A NAMe="idx1073751032"></a><a nAME="idx1073751033"></A><a name="idx1073751034"></a><a name="idx1073751035"></a><a name="idx1073751036"></a><a nAme="idx1073751037"></A><a naMe="idx1073751038"></a><a nAme="idx1073751039"></a><A NAMe="idx1073751040"></a></p>

					<pRE>
						
PyObject* PyNumber_Coerce(PyObject **p1, PyObject **p2)

					</PRe>

					<p>This function takes the addresses of two variables of type <tt CLASs="monofont">PyObject*.</tt> If the objects pointed to by <tT CLAss="monofont">*p1</tt> and <tt class="monofont">*p2</tt> have the same type, increment their reference count and return <tt class="monofont">0</Tt> (success). If the objects can be converted to a common numeric type, replace <tT claSs="monofont">*p1</tt> and <tT claSS="monofont">*p2</TT> by their converted value (with <i>new</i> reference counts), and return <tt CLASs="monofont">0.</tt> If no conversion is possible, or if some other error occurs, return <tT CLAss="monofont">-1</tt> (failure) and don't increment the reference counts. The call <TT CLass="monofont">PyNumber_Coerce(&amp;o1, &amp;o2)</tt> is equivalent to the Python statement <tt class="monofont">"o1, o2 = coerce(o1, o2)".</tt></p>

					<pre>
						
PyObject* PyNumber_Int(PyObject *o)

					</prE>

					<p>Return value: New reference. Returns the <tT claSs="monofont">o</tt> converted to an integer object on success, or <tT claSS="monofont">NULL</TT> on failure. This is the equivalent of the Python expression <tt clASS="monofont">"int(o)".</Tt></p>

					<prE>
						
PyObject* PyNumber_Long(PyObject *o)

					</PRE>

					<p>Return value: New reference. Returns the <tt cLASS="monofont">o</tt> converted to a long integer object on success, or <tt class="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <tt class="monofont">"long(o)".</tt></P>

					<prE>
						
PyObject* PyNumber_Float(PyObject *o)

					</pre>

					<P>Return value: New reference. Returns the <tt clAss="monofont">o</tT> converted to a float object on success, or <TT Class="monofont">NULL</TT> on failure. This is the equivalent of the Python expression <TT clasS="monofont">"float(o)".</TT><A name="idx1073751041"></A><A NAme="idx1073751042"></a><a name="idx1073751043"></a><a name="idx1073751044"></a></p>

				
				<h4>Sequence Protocol</h4>
					<prE>
						
int PySequence_Check(PyObject *o)

					</prE>

					<p>Returns <tt Class="monofont">1</Tt> if the object provides sequence protocol, and <tt CLASs="monofont">0</tt> otherwise. This function always succeeds.</p>

					<PRE>
						
int PySequence_Length(PyObject *o)

					</Pre>

					<p>Returns the number of objects in sequence; <tT CLAss="monofont">o</tt> on success, and <TT CLass="monofont">-1</tt> on failure. For objects that do not provide sequence protocol, this is equivalent to the Python expression <tt class="monofont">"len(o)".</tt></p>

					<pre>
						
PyObject* PySequence_Concat(PyObject *o1, PyObject *o2)

					</prE>

					<p>Return value: New reference. Returns the concatenation of <tT claSs="monofont">o1</tt> and <tT claSS="monofont">o2</TT> on success, and <tt clASS="monofont">NULL</Tt> on failure. This is the equivalent of the Python expression <tt cLASS="monofont">"o1 + o2".</tt><a nAME="idx1073751045"></A><a name="idx1073751046"></a><a name="idx1073751047"></a><a name="idx1073751048"></a><a nAme="idx1073751049"></A><a naMe="idx1073751050"></a><a nAme="idx1073751051"></a><A NAMe="idx1073751052"></a><a nAME="idx1073751053"></A><a namE="idx1073751054"></A><A Name="idx1073751055"></a></P>

					<PRE>
						
PyObject* PySequence_Repeat(PyObject *o, int count)

					</pre>

					<p>Return value: New reference. Returns the result of repeating sequence object <tt class="monofont">o</tt> count times, or <tt class="monofont">NULL</Tt> on failure. This is the equivalent of the Python expression <tT claSs="monofont">"o * count".</tt></p>

					<Pre>
						
PyObject* PySequence_GetItem(PyObject *o, int i)

					</pRE>

					<P>Return value: New reference. Returns the <Tt claSS="monofont">i</TT>th element of <tt clASS="monofont">o,</Tt> or <tt cLASS="monofont">NULL</tt> on failure. This is the equivalent of the Python expression <tt class="monofont">"o[i]".</tt></p>

⌨️ 快捷键说明

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