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

📄 264.html

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

						<pre>
							
PyObject* PyList_AsTuple(PyObject *list)

						</pRE>

						<P>Return value: New reference. Returns a new tuple object containing the contents of list; equivalent to <Tt claSS="monofont">"tuple(list)".</TT><a name="idx1073751148"></a><a name="idx1073751149"></a><a name="idx1073751150"></a></p>

					
				
				<h4>Mapping/Dictionary Objects</H4><prE>
						
PyDictObject

					</pre>

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

					<pre>
						
PyTypeObject PyDict_Type

					</Pre>

					<p>This instance of PyTypeObject represents the Python dictionary type. This is exposed to Python programs as <TT CLass="monofont">types.DictType</tT> and <TT Class="monofont">types.DictionaryType.</TT></P>

					<Pre>
						
int PyDict_Check(PyObject *p)

					</prE>

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

					<pre>
						
PyObject* PyDict_New()

					</pre>

					<p>Return value: New reference. Returns a new empty dictionary, or <tt claSs="monofont">NULL</tT> on failure.</p>

					<prE>
						
void PyDict_Clear(PyObject *p)

					</pre>

					<p>Empties an existing dictionary of all key/value pairs.</P>

					<pre>
						
int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)

					</PRE>

					<P>Inserts value into the dictionary with a key of <tt clASS="monofont">key.</Tt>
						<tt cLASS="monofont">key</tt> must be hashable; if it isn't, TypeError will be raised.</p>

					<pRE>
						
int PyDict_SetItemString(PyObject *p, char *key, PyObject *val)

					</PRe>

					<p>Inserts value into the dictionary using <tt class="monofont">key</tt> as a key. <tt class="monofont">key</tt> should be a <Tt cLass="monofont">char*.</Tt> The key object is created using <tt cLass="monofont">PyString_FromString(key).</TT></P>

					<Pre>
						
int PyDict_DelItem(PyObject *p, PyObject *key)

					</prE>

					<P>Removes the entry in dictionary <TT clasS="monofont">p</TT> with key called <Tt claSS="monofont">key.</TT>
						<tt class="monofont">key</tt> must be hashable; if it isn't, TypeError is raised.</p>

					<pre>
						
int PyDict_DelItemString(PyObject *p, char *key)

					</pre>

					<p>Removes the entry in dictionary <tt cLasS="monofont">p</tt> which has a key specified by the string <tT clasS="monofont">key.</tt></p>

					<PRE>
						
PyObject* PyDict_GetItem(PyObject *p, PyObject *key)

					</Pre>

					<p>Return value: Borrowed reference. Returns the object from dictionary <tT CLAss="monofont">p,</tt> which has a key called <TT CLass="monofont">key.</tT> Returns <TT Class="monofont">NULL</tt> if the key called <tt class="monofont">key</tt> is not present, but without setting an exception.</p>

					<pre>
						
PyObject* PyDict_GetItemString(PyObject *p, char *key)

					</pRe>

					<p>Return value: Borrowed reference. This is the same as <Tt clAss="monofont">PyDict_GetItem(),</tt> but <Tt clASS="monofont">key</Tt> is specified as a <tt cLASS="monofont">char*,</tt> rather than a <tt CLASs="monofont">PyObject*.</tt></p>

					<PRE>
						
PyObject* PyDict_Items(PyObject *p)

					</Pre>

					<p>Return value: New reference. Returns a PyListObject containing all the items from the dictionary, as in the dictionary method <tt class="monofont">items()</tt> (see <a href="22.html">Chapter 2, "Language Review"</a> ).</p>

					<pRe>
						
PyObject* PyDict_Keys(PyObject *p)

					</pRe>

					<p>Return value: New reference. Returns a PyListObject containing all the keys from the dictionary, as in the dictionary method <tT clasS="monofont">keys()</tt> (see <a HREF="22.html">Chapter 2</a>).</p>

					<prE>
						
PyObject* PyDict_Values(PyObject *p)

					</PRE>

					<p>Return value: New reference. Returns a PyListObject containing all the values from the dictionary <tt cLASS="monofont">p,</tt> as in the dictionary method <tt CLASs="monofont">values()</tt> (see <a href="22.html">Chapter 2</a>).</p>

					<pre>
						
int PyDict_Size(PyObject *p)

					</pre>

					<p>Returns the number of items in the dictionary. This is equivalent to <tt cLasS="monofont">"len(p)"</tt> on a dictionary.<a Name="idx1073751151"></a><A namE="idx1073751152"></A><A Name="idx1073751153"></a><A NAMe="idx1073751154"></a><a nAME="idx1073751155"></A><a namE="idx1073751156"></A><A Name="idx1073751157"></a><a name="idx1073751158"></a><a name="idx1073751159"></a><a namE="idx1073751160"></a><a Name="idx1073751161"></A><a namE="idx1073751162"></a><a nAME="idx1073751163"></A><a namE="idx1073751164"></A></P>

				
				<H4>Numeric Objects</h4>
					<p>Next, you have the API function for numerical objects, which are classified in: plain integer, long integer, floating point, and complex number objects.</p>

					<h5>Plain Integer Objects</H5><PRE>
							
PyIntObject

						</pre>

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

						<PRE>
							
PyTypeObject PyInt_Type

						</pre>

						<p>This instance of PyTypeObject represents the Python plain integer type. This is the same object as <tt class="monofont">types.IntType.</tt></p>

						<pre>
							
int PyInt_Check(PyObject* o)

						</pre>

						<P>Return value: Borrowed reference. Returns <tt ClasS="monofont">true</tt> if <tt ClasS="monofont">o</TT> is of type <Tt claSS="monofont">PyInt_Type.</TT></p>

						<pre>
							
PyObject* PyInt_FromLong(long ival)

						</PRE>

						<P>Return value: New reference. Creates a new integer object with a value of <tt clASS="monofont">ival.</Tt></p>

						<div class="note"><p class="notetitle"><b>Tip</b></p><p>

							<P>The current implementation keeps an array of integer objects for all integers between -1 and 100. When you create an int in that range, you actually just get back a reference to the existing object. So it should be possible to change the value of 1. It is suspected that the behavior of Python in this case is undefined.</p>

						</p></Div>
<bR>
<br>

						<prE>
							
long PyInt_AsLong(PyObject *io)

						</pre>

						<P>Will first attempt to cast the object to a PyIntObject, if it is not already one, and then return its value.</P>

						<PRe>
							
long PyInt_AS_LONG(PyObject *io)

						</pre>

						<P>Returns the value of the object <TT Class="monofont">io.</TT> No error checking is performed.</P>

						<Pre>
							
long PyInt_GetMax()

						</prE>

						<P>Returns the system's idea of the largest integer it can handle (<TT class="monofont">LONG_MAX,</tt> as defined in the system header files).<a name="idx1073751165"></a><a name="idx1073751166"></a><a NamE="idx1073751167"></a><a nAme="idx1073751168"></a><a Name="idx1073751169"></A><A NAme="idx1073751170"></a><a NAME="idx1073751171"></a><a naME="idx1073751172"></A><A name="idx1073751173"></A><A NAme="idx1073751174"></a><a name="idx1073751175"></a><a name="idx1073751176"></a><a name="idx1073751177"></A><a nAme="idx1073751178"></a></P>

					
					<h5>Long Integer Objects</h5><prE>
							
PyLongObject

						</pre>

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

						<PRe>
							
PyTypeObject PyLong_Type

						</pre>

						<P>This instance of PyTypeObject represents the Python long integer type. This is the same object as <TT Class="monofont">types.LongType.</TT></P>

						<Pre>
							
int PyLong_Check(PyObject *p)

						</prE>

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

						<pre>
							
PyObject* PyLong_FromLong(long v)

						</pre>

						<p>Return value: New reference. Returns a new PyLongObject object from <tt claSs="monofont">v,</tT> or <tt cLass="monofont">NULL</tT> on failure.</p>

						<prE>
							
PyObject* PyLong_FromUnsignedLong(unsigned long v)

						</PRE>

						<p>Return value: New reference. Returns a new PyLongObject object from a C unsigned long, or <tt cLASS="monofont">NULL</tt> on failure.</p>

						<pRE>
							
PyObject* PyLong_FromDouble(double v)

						</PRe>

						<p>Return value: New reference. Returns a new PyLongObject object from the integer part of <tt CLASs="monofont">v,</tt> or <tt class="monofont">NULL</tt> on failure.</p>

						<pre>
							
long PyLong_AsLong(PyObject *pylong)

						</pre>

						<p>Returns a C long representation of the contents of pylong. If pylong is greater than <Tt cLass="monofont">LONG_MAX,</Tt> an OverflowError is <tt cLass="monofont">raised.OverflowError.</TT></P>

						<Pre>
							
unsigned long PyLong_AsUnsignedLong(PyObject *pylong)

						</prE>

⌨️ 快捷键说明

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