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

📄 264.html

📁 Python Ebook Python&XML
💻 HTML
📖 第 1 页 / 共 5 页
字号:
						<P>Returns a C unsigned long representation of the contents of <TT clasS="monofont">pylong.</TT> If pylong is greater than <Tt claSS="monofont">ULONG_MAX,</TT> an OverflowError is <tt class="monofont">raised.OverflowError.</tt></p>

						<pre>
							
double PyLong_AsDouble(PyObject *pylong)

						</pre>

						<p>Returns a C double representation of the contents of <tt cLasS="monofont">pylong.</tt></p>

						<Pre>
							
PyObject* PyLong_FromString(char *str, char **pend, int base)

						</prE>

						<p>Return value: New reference. Returns a new PyLongObject based on the string value in <tt CLASs="monofont">str,</tt> which is interpreted according to the radix in base. If <tT CLAss="monofont">pend</tt> is non-<TT CLass="monofont">NULL,</tT>
							<TT Class="monofont">*pend</tt> will point to the first character in <tt class="monofont">str</tt> which follows the representation of the number. If base is 0, the radix will be determined based on the leading characters of <tt claSs="monofont">str</tT>: if <tt cLass="monofont">str</tT> starts with <tt cLASS="monofont">0x</tt> or <tt CLASs="monofont">0X,</tt> radix 16 will be used; if <tT CLAss="monofont">str</tt> starts with <TT CLass="monofont">0,</tt> radix 8 will be used; otherwise, radix 10 will be used. If base is not <tt class="monofont">0,</tt> it must be between 2 and 36, inclusive. Leading spaces are ignored. If there are no digits, ValueError will be raised.<a name="idx1073751179"></a><A naMe="idx1073751180"></a><a Name="idx1073751181"></a><A namE="idx1073751182"></A><A Name="idx1073751183"></a><A NAMe="idx1073751184"></a><a nAME="idx1073751185"></A></p>

					
					<h5>Floating Point Objects</h5><pRE>
							
PyFloatObject

						</PRe>

						<p>This subtype of PyObject represents a Python floating point object.</p>

						<pre>
							
PyTypeObject PyFloat_Type

						</pre>

						<p>This instance of PyTypeObject represents the Python floating point type. This is the same object as <tt class="monofont">types.FloatType.</tt></p>

						<Pre>
							
int PyFloat_Check(PyObject *p)

						</Pre>

						<p>Returns <Tt claSs="monofont">true</tt> if its argument is a PyFloatObject.</P>

						<PRE>
							
PyObject* PyFloat_FromDouble(double v)

						</pre>

						<p>Return value: New reference. Creates a PyFloatObject object from <TT CLass="monofont">v,</tT> or <TT Class="monofont">NULL</TT> on failure.</P>

						<Pre>
							
double PyFloat_AsDouble(PyObject *pyfloat)

						</pre>

						<p>Returns a C double representation of the contents of <tt class="monofont">pyfloat.</tt></p>

						<pre>
							
double PyFloat_AS_DOUBLE(PyObject *pyfloat)

						</pRe>

						<p>Returns a C double representation of the contents of <Tt clAss="monofont">pyfloat,</tt> but without error checking.<A namE="idx1073751186"></A><A Name="idx1073751187"></a><A NAMe="idx1073751188"></a></p>

					
					<h5>Complex Number Objects</H5>
						<P>Python's complex number objects are implemented as two distinct types when viewed from the C API: one is the Python object exposed to Python programs, and the other is a C structure that represents the actual complex number value. The API provides functions for working with both.<A Name="idx1073751189"></a><A NAMe="idx1073751190"></a><a name="idx1073751191"></a><a name="idx1073751192"></a><a name="idx1073751193"></a><A naMe="idx1073751194"></a><a Name="idx1073751195"></a><A namE="idx1073751196"></A><A Name="idx1073751197"></a><A NAMe="idx1073751198"></a><a nAME="idx1073751199"></A><a namE="idx1073751200"></A><A Name="idx1073751201"></a><a name="idx1073751202"></a></p>

						<h5>Complex Numbers as C Structures</h5>
							<p>Note that the functions which accept these structures as parameters and return them as results do so by value rather than dereferencing them through pointers. This is consistent throughout the API.</p>

							<pre>
								
Py_complex

							</prE>

							<p>This is the C structure that corresponds to the value portion of a Python complex number object. Most of the functions for dealing with complex number objects use structures of this type as input or output values, as appropriate. It is defined as</p>

							<Pre>
								
typedef struct {
   double real;
   double imag;
} Py_complex;

Py_complex _Py_c_sum(Py_complex left, Py_complex right)

							</pRe>

							<p>Returns the sum of two complex numbers, using the C <tt ClasS="monofont">Py_complex</TT> representation.</P>

							<pre>
								
Py_complex _Py_c_diff(Py_complex left, Py_complex right)

							</pRE>

							<P>Returns the difference between two complex numbers, using the C <Tt claSS="monofont">Py_complex</TT> representation.</p>

							<pre>
								
Py_complex _Py_c_neg(Py_complex complex)

							</PRE>

							<P>Returns the negation of the complex number complex, using the C <tt class="monofont">Py_complex</tt> representation.</p>

							<pre>
								
Py_complex _Py_c_prod(Py_complex left, Py_complex right)

							</pre>

							<p>Returns the product of two complex numbers, using the C <tt cLasS="monofont">Py_complex</tt> representation.</p>

							<Pre>
								
Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)

							</prE>

							<p>Returns the quotient of two complex numbers, using the C <tt CLASs="monofont">Py_complex</tt> representation.</p>

							<PRE>
								
Py_complex _Py_c_pow(Py_complex num, Py_complex exp)

							</Pre>

							<p>Returns the exponentiation of <tT CLAss="monofont">num</tt> by <TT CLass="monofont">exp,</tt> using the C <tt class="monofont">Py_complex</tt> representation.<a name="idx1073751203"></a><A naMe="idx1073751204"></a></p>

						
						<H5>Complex Numbers as Python Objects</h5><pre>
								
PyComplexObject

							</Pre>

							<p>This subtype of PyObject represents a Python complex number object.</P>

							<PRE>
								
PyTypeObject PyComplex_Type

							</pre>

							<p>This instance of PyTypeObject represents the Python complex number type.</P>

							<PRE>
								
int PyComplex_Check(PyObject *p)

							</pre>

							<p>Returns <TT CLass="monofont">true</tT> if its argument is a <TT Class="monofont">PyComplexObject.</tt></p>

							<pre>
								
PyObject* PyComplex_FromCComplex(Py_complex v)

							</pre>

							<p>Return value: New reference. Creates a new Python complex number object from a C <tt clasS="monofont">Py_complex</tt> value.</P>

							<pre>
								
PyObject* PyComplex_FromDoubles(double real, double imag)

							</Pre>

							<p>Return value: New reference. Returns a new <tT claSS="monofont">PyComplexObject</TT> object from <tt clASS="monofont">real</Tt> and <tt cLASS="monofont">imag.</tt></p>

							<pRE>
								
double PyComplex_RealAsDouble(PyObject *op)

							</PRe>

							<p>Returns the real part of <tt class="monofont">op</tt> as a C double.</p>

							<pre>
								
double PyComplex_ImagAsDouble(PyObject *op)

							</pre>

							<p>Returns the imaginary part of <tT clAss="monofont">op</tT> as a C double.</p>

							<pre>
								
Py_complex PyComplex_AsCComplex(PyObject *op)

							</Pre>

							<p>Returns the <TT CLass="monofont">Py_complex</tT> value of the complex number <TT Class="monofont">op.</TT><A Name="idx1073751205"></a><A NAMe="idx1073751206"></a><a name="idx1073751207"></a><a name="idx1073751208"></a><a name="idx1073751209"></a><A naMe="idx1073751210"></a><a Name="idx1073751211"></a><A namE="idx1073751212"></A><A Name="idx1073751213"></a><A NAMe="idx1073751214"></a><a nAME="idx1073751215"></A><a namE="idx1073751216"></A><A Name="idx1073751217"></a><a name="idx1073751218"></a><a name="idx1073751219"></a><a namE="idx1073751220"></a></p>

						
					
				
				<H4>Other Objects</h4>
					<p>Next, you have the list of API function for all the other objects, including File, Module, and C Objects.</p>

					<H5>File Objects</h5>
						<p>Python's built-in file objects are implemented entirely on the FILE* support from the C standard library. This is an implementation detail and might change in future releases of Python.</p>

						<pRe>
							
PyFileObject

						</prE>

						<P>This subtype of PyObject represents a Python file object.</P>

						<Pre>
							
PyTypeObject PyFile_Type

						</prE>

						<P>This instance of PyTypeObject represents the Python file type. This is exposed to Python programs as <TT clasS="monofont">types.FileType.</TT></P>

						<pre>
							
int PyFile_Check(PyObject *p)

						</pRE>

						<P>Returns <Tt class="monofont">true</tt> if its argument is a <tt class="monofont">PyFileObject.</tt></p>

						<prE>
							
PyObject* PyFile_FromString(char *filename, char *mode)

						</prE>

						<p>Return value: New reference. On success, returns a new file object that is opened on the file given by filename, with a file mode given by mode, where mode has the same semantics as the standard C routine <tt Class="monofont">fopen().</Tt> On failure, returns <tt CLASs="monofont">NULL.</tt></p>

						<PRE>
							
PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int
(*close)(FILE*))

						</Pre>

						<p>Return value: New reference. Creates a new <tT CLAss="monofont">PyFileObject</tt> from the already-open standard C file pointer, <TT CLass="monofont">fp.</tt> The function close will be called when the file should be closed. Returns <tt class="monofont">NULL</tt> on failure.</p>

						<pre>
							
FILE* PyFile_AsFile(PyFileObject *p)

						</prE>

						<p>Returns the file object associated with <tT claSs="monofont">p</tt> as a <tT claSS="monofont">FILE*.</TT></p>

						<pre>
							
PyObject* PyFile_GetLine(PyObject *p, int n)

						</PRE>

⌨️ 快捷键说明

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