日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)Python教程:整數(shù)型對(duì)象

整數(shù)型對(duì)象

所有整數(shù)都實(shí)現(xiàn)為長(zhǎng)度任意的長(zhǎng)整數(shù)對(duì)象。

創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的零陵網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

在出錯(cuò)時(shí),大多數(shù) PyLong_As* API 都會(huì)返回 (return type)-1,這與數(shù)字無(wú)法區(qū)分開(kāi)。請(qǐng)采用 PyErr_Occurred() 來(lái)加以區(qū)分。

type PyLongObject

Part of the Limited API (as an opaque struct).

表示 python 整數(shù)對(duì)象的 PyObject 子類型。

PyTypeObject PyLong_Type

Part of the Stable ABI.

這個(gè) PyTypeObject 的實(shí)例表示 Python 的整數(shù)類型。與 Python 語(yǔ)言中的 int 相同。

int PyLong_Check(PyObject *p)

如果參數(shù)是 PyLongObject 或 PyLongObject 的子類型,則返回 True。該函數(shù)一定能夠執(zhí)行成功。

int PyLong_CheckExact(PyObject *p)

如果其參數(shù)屬于 PyLongObject,但不是 PyLongObject 的子類型則返回真值。 此函數(shù)總是會(huì)成功執(zhí)行。

PyObject *PyLong_FromLong(long v)

Return value: New reference. Part of the Stable ABI.

v 返回一個(gè)新的 PyLongObject 對(duì)象,失敗時(shí)返回 NULL 。

當(dāng)前的實(shí)現(xiàn)維護(hù)著一個(gè)整數(shù)對(duì)象數(shù)組,包含 -5256 之間的所有整數(shù)對(duì)象。 若創(chuàng)建一個(gè)位于該區(qū)間的 int 時(shí),實(shí)際得到的將是對(duì)已有對(duì)象的引用。

PyObject *PyLong_FromUnsignedLong(unsigned long v)

Return value: New reference. Part of the Stable ABI.

Return a new PyLongObject object from a C unsigned long, or NULL on failure.

PyObject *PyLong_FromSsize_t(Py_ssize_t v)

Return value: New reference. Part of the Stable ABI.

由 C Py_ssize_t 返回一個(gè)新的 PyLongObject 對(duì)象,失敗時(shí)返回 NULL 。

PyObject *PyLong_FromSize_t(size_t v)

Return value: New reference. Part of the Stable ABI.

由 C size_t 返回一個(gè)新的 PyLongObject 對(duì)象,失敗則返回 NULL 。

PyObject *PyLong_FromLongLong(long long v)

Return value: New reference. Part of the Stable ABI.

Return a new PyLongObject object from a C long long, or NULL on failure.

PyObject *PyLong_FromUnsignedLongLong(unsigned long long v)

Return value: New reference. Part of the Stable ABI.

Return a new PyLongObject object from a C unsigned long long, or NULL on failure.

PyObject *PyLong_FromDouble(double v)

Return value: New reference. Part of the Stable ABI.

v 的整數(shù)部分返回一個(gè)新的 PyLongObject 對(duì)象,失敗則返回 NULL 。

PyObject *PyLong_FromString(const char *str, char **pend, int base)

Return value: New reference. Part of the Stable ABI.

根據(jù) str 字符串值返回一個(gè)新的 PyLongObject ,base 指定了整數(shù)的基。如果 pend 不為 NULL ,則 /\pend 將指向str 中表示數(shù)字部分后面的第一個(gè)字符。如果base0 ,str 將采用 整數(shù)字面值 的定義進(jìn)行解釋;這時(shí)非零十進(jìn)制數(shù)的前導(dǎo)零會(huì)觸發(fā) ValueError 。如果base* 不為 0 ,則須位于 236 之間(含 2 和 36)?;蠹皵?shù)字之間的前導(dǎo)空格、單下劃線將被忽略。如果不存在數(shù)字,將觸發(fā) ValueError。

PyObject *PyLong_FromUnicodeObject(PyObject *u, int base)

Return value: New reference.

將字符串 u 中的 Unicode 數(shù)字序列轉(zhuǎn)換為 Python 整數(shù)值。

3.3 新版功能.

PyObject *PyLong_FromVoidPtr(void *p)

Return value: New reference. Part of the Stable ABI.

從指針 p 創(chuàng)建一個(gè) Python 整數(shù)??梢允褂?PyLong_AsVoidPtr() 返回的指針值。

long PyLong_AsLong(PyObject *obj)

Part of the Stable ABI.

Return a C long representation of obj. If obj is not an instance of PyLongObject, first call its __index__() method (if present) to convert it to a PyLongObject.

Raise OverflowError if the value of obj is out of range for a long.

出錯(cuò)則返回 -1 。請(qǐng)用 PyErr_Occurred() 找出具體問(wèn)題。

在 3.8 版更改: 如果可用將使用 __index__()。

在 3.10 版更改: 本函數(shù)不再使用 __int__() 。

long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)

Part of the Stable ABI.

Return a C long representation of obj. If obj is not an instance of PyLongObject, first call its __index__() method (if present) to convert it to a PyLongObject.

如果 obj 的值大于 LONG_MAX 或小于 LONG_MIN,則會(huì)把 \overflow 分別置為``1`` 或 -1,并返回 1;否則,將*overflow 置為 0。如果發(fā)生其他異常,則會(huì)按常規(guī)把*overflow* 置為 0,并返回 -1。

出錯(cuò)則返回 -1 。請(qǐng)用 PyErr_Occurred() 找出具體問(wèn)題。

在 3.8 版更改: 如果可用將使用 __index__()。

在 3.10 版更改: 本函數(shù)不再使用 __int__() 。

long long PyLong_AsLongLong(PyObject *obj)

Part of the Stable ABI.

Return a C long long representation of obj. If obj is not an instance of PyLongObject, first call its __index__() method (if present) to convert it to a PyLongObject.

Raise OverflowError if the value of obj is out of range for a long long.

出錯(cuò)則返回 -1 。請(qǐng)用 PyErr_Occurred() 找出具體問(wèn)題。

在 3.8 版更改: 如果可用將使用 __index__()。

在 3.10 版更改: 本函數(shù)不再使用 __int__()

long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)

Part of the Stable ABI.

Return a C long long representation of obj. If obj is not an instance of PyLongObject, first call its __index__() method (if present) to convert it to a PyLongObject.

如果 obj 的值大于 LLONG_MAX 或小于 LLONG_MIN,則按常規(guī)將 \overflow 分別置為 1-1,并返回 -1,否則將*overflow 置為 0。如果觸發(fā)其他異常則*overflow* 置為 0 并返回 -1。

出錯(cuò)則返回 -1 。請(qǐng)用 PyErr_Occurred() 找出具體問(wèn)題。

3.2 新版功能.

在 3.8 版更改: 如果可用將使用 __index__()。

在 3.10 版更改: 本函數(shù)不再使用 __int__()

Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)

Part of the Stable ABI.

返回 pylong 的 C 語(yǔ)言 Py_ssize_t 形式。pylong 必須是 PyLongObject 的實(shí)例。

如果 pylong 的值超出了 Py_ssize_t 的取值范圍則會(huì)引發(fā) OverflowError。

出錯(cuò)則返回 -1 。請(qǐng)用 PyErr_Occurred() 找出具體問(wèn)題。

unsigned long PyLong_AsUnsignedLong(PyObject *pylong)

Part of the Stable ABI.

Return a C unsigned long representation of pylong. pylong must be an instance of PyLongObject.

Raise OverflowError if the value of pylong is out of range for a unsigned long.

出錯(cuò)時(shí)返回 (unsigned long)-1 ,請(qǐng)利用 PyErr_Occurred() 辨別具體問(wèn)題。

size_t PyLong_AsSize_t(PyObject *pylong)

Part of the Stable ABI.

返回 pylong 的 C 語(yǔ)言 size_t 形式。pylong 必須是 PyLongObject 的實(shí)例。

如果 pylong 的值超出了 size_t 的取值范圍則會(huì)引發(fā) OverflowError。

出錯(cuò)時(shí)返回 (size_t)-1 ,請(qǐng)利用 PyErr_Occurred() 辨別具體問(wèn)題。

unsigned long long PyLong_AsUnsignedLongLong(PyObject *pylong)

Part of the Stable ABI.

Return a C unsigned long long representation of pylong. pylong must be an instance of PyLongObject.

Raise OverflowError if the value of pylong is out of range for an unsigned long long.

出錯(cuò)時(shí)返回 (unsigned long long)-1,請(qǐng)利用 PyErr_Occurred() 辨別具體問(wèn)題。

在 3.1 版更改: 現(xiàn)在 pylong 為負(fù)值會(huì)觸發(fā) OverflowError,而不是 TypeError。

unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)

Part of the Stable ABI.

Return a C unsigned long representation of obj. If obj is not an instance of PyLongObject, first call its __index__() method (if present) to convert it to a PyLongObject.

If the value of obj is out of range for an unsigned long, return the reduction of that value modulo ULONG_MAX + 1.

出錯(cuò)時(shí)返回 (unsigned long)-1,請(qǐng)利用 PyErr_Occurred() 辨別具體問(wèn)題。

在 3.8 版更改: 如果可用將使用 __index__()。

在 3.10 版更改: 本函數(shù)不再使用 __int__()

unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)

Part of the Stable ABI.

Return a C unsigned long long representation of obj. If obj is not an instance of PyLongObject, first call its __index__() method (if present) to convert it to a PyLongObject.

If the value of obj is out of range for an unsigned long long, return the reduction of that value modulo ULLONG_MAX + 1.

出錯(cuò)時(shí)返回 (unsigned long long)-1,請(qǐng)利用 PyErr_Occurred() 辨別具體問(wèn)題。

在 3.8 版更改: 如果可用將使用 __index__()。

在 3.10 版更改: 本函數(shù)不再使用 __int__() 。

double PyLong_AsDouble(PyObject *pylong)

Part of the Stable ABI.

Return a C double representation of pylong. pylong must be an instance of PyLongObject.

Raise OverflowError if the value of pylong is out of range for a double.

出錯(cuò)時(shí)返回 -1.0 ,請(qǐng)利用 PyErr_Occurred() 辨別具體問(wèn)題。

void *PyLong_AsVoidPtr(PyObject *pylong)

Part of the Stable ABI.

Convert a Python integer pylong to a C void pointer. If pylong cannot be converted, an OverflowError will be raised. This is only assured to produce a usable void pointer for values created with PyLong_FromVoidPtr().

出錯(cuò)時(shí)返回 NULL,請(qǐng)利用 PyErr_Occurred() 辨別具體問(wèn)題。


文章標(biāo)題:創(chuàng)新互聯(lián)Python教程:整數(shù)型對(duì)象
網(wǎng)頁(yè)鏈接:http://www.dlmjj.cn/article/cdgphed.html