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

Python (195) 2023-06-26 20:35:49

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电脑。)

THE END

发表回复