品易云推流 关闭
文章详情页
文章 > Python基础教程 > python long函数是什么?如何使用?

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

long函数

头像

小妮浅浅

2021-04-19 11:23:097689浏览 · 0收藏 · 0评论

1.说明

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

2.语法

class long(x, base=10)

3.参数

x -- 字符串或数字。

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

4.返回值

返回长整型数。

5.实例

def _is_integer(x):
    """Determine whether some object ``x`` is an
    integer type (int, long, etc). This is part of the 
    ``fixes`` module, since Python 3 removes the long
    datatype, we have to check the version major.
 
    Parameters
    ----------
 
    x : object
        The item to assess whether is an integer.
 
 
    Returns
    -------
 
    bool
        True if ``x`` is an integer type
    """
    return (not isinstance(x, (bool, np.bool))) and \
        isinstance(x, (numbers.Integral, int, np.int, np.long, long))  # no long type in python 3

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

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


关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图