日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

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

新聞中心

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

整數(shù)型對象

所有整數(shù)都實現(xiàn)為長度任意的長整數(shù)對象。

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

在出錯時,大多數(shù) PyLong_As* API 都會返回 (return type)-1,這與數(shù)字無法區(qū)分開。請采用 PyErr_Occurred() 來加以區(qū)分。

type PyLongObject

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

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

PyTypeObject PyLong_Type

Part of the Stable ABI.

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

int PyLong_Check(PyObject *p)

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

int PyLong_CheckExact(PyObject *p)

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

PyObject *PyLong_FromLong(long v)

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

v 返回一個新的 PyLongObject 對象,失敗時返回 NULL

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

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 返回一個新的 PyLongObject 對象,失敗時返回 NULL 。

PyObject *PyLong_FromSize_t(size_t v)

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

由 C size_t 返回一個新的 PyLongObject 對象,失敗則返回 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ù)部分返回一個新的 PyLongObject 對象,失敗則返回 NULL 。

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

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

根據(jù) str 字符串值返回一個新的 PyLongObject ,base 指定了整數(shù)的基。如果 pend 不為 NULL ,則 /\pend 將指向str 中表示數(shù)字部分后面的第一個字符。如果base0 ,str 將采用 整數(shù)字面值 的定義進(jìn)行解釋;這時非零十進(jìn)制數(shù)的前導(dǎo)零會觸發(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)建一個 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.

出錯則返回 -1 。請用 PyErr_Occurred() 找出具體問題。

在 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,則會把 \overflow 分別置為``1`` 或 -1,并返回 1;否則,將*overflow 置為 0。如果發(fā)生其他異常,則會按常規(guī)把*overflow* 置為 0,并返回 -1。

出錯則返回 -1 。請用 PyErr_Occurred() 找出具體問題。

在 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.

出錯則返回 -1 。請用 PyErr_Occurred() 找出具體問題。

在 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。

出錯則返回 -1 。請用 PyErr_Occurred() 找出具體問題。

3.2 新版功能.

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

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

Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)

Part of the Stable ABI.

返回 pylong 的 C 語言 Py_ssize_t 形式。pylong 必須是 PyLongObject 的實例。

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

出錯則返回 -1 。請用 PyErr_Occurred() 找出具體問題。

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.

出錯時返回 (unsigned long)-1 ,請利用 PyErr_Occurred() 辨別具體問題。

size_t PyLong_AsSize_t(PyObject *pylong)

Part of the Stable ABI.

返回 pylong 的 C 語言 size_t 形式。pylong 必須是 PyLongObject 的實例。

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

出錯時返回 (size_t)-1 ,請利用 PyErr_Occurred() 辨別具體問題。

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.

出錯時返回 (unsigned long long)-1,請利用 PyErr_Occurred() 辨別具體問題。

在 3.1 版更改: 現(xiàn)在 pylong 為負(fù)值會觸發(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.

出錯時返回 (unsigned long)-1,請利用 PyErr_Occurred() 辨別具體問題。

在 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.

出錯時返回 (unsigned long long)-1,請利用 PyErr_Occurred() 辨別具體問題。

在 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.

出錯時返回 -1.0 ,請利用 PyErr_Occurred() 辨別具體問題。

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().

出錯時返回 NULL,請利用 PyErr_Occurred() 辨別具體問題。


當(dāng)前文章:創(chuàng)新互聯(lián)Python教程:整數(shù)型對象
當(dāng)前鏈接:http://www.5511xx.com/article/cdgphed.html