python long函数是什么?如何使用?

1.说明

Python long() 函数将数字或字符串转换为一个长整型。

2.语法

classlong(x,base=10)

3.参数

x -- 字符串或数字。

base -- 可选,进制数,默认十进制。

4.返回值

返回长整型数。

5.实例

def_is_integer(x):
"""Determinewhethersomeobject``x``isan
integertype(int,long,etc).Thisispartofthe
``fixes``module,sincePython3removesthelong
datatype,wehavetochecktheversionmajor.

Parameters
----------

x:object
Theitemtoassesswhetherisaninteger.


Returns
-------

bool
Trueif``x``isanintegertype
"""
return(notisinstance(x,(bool,np.bool)))and\
isinstance(x,(numbers.Integral,int,np.int,np.long,long))#nolongtypeinpython3

以上就是python long函数在数字和字符串转化方面的应用,小伙伴们有没有成功转换成长整型呢,一定要按照上方小编的代码哦~

(推荐操作系统:windows7系统、Python 3.9.1,DELL G3电脑。)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。