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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值