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

2025-12-01 0 55,840

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

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:以上部本文内容由互联网用户自发贡献,本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。投诉邮箱:3758217903@qq.com

ZhiUp资源网 python基础 python long函数是什么?如何使用? https://www.zhiup.top/2874.html

相关