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

1,440次阅读
没有评论
python

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

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函数在数字和字符串转化方面的应用,小伙伴们有没有成功转换成长整型呢,一定要按照上方小编的代码哦~

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:wuyou2021-06-30发表,共计737字。
新手QQ群:570568346,欢迎进群讨论 Python51学习