• 技术文章 >Python技术 >Python基础教程

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

    小妮浅浅小妮浅浅2021-04-19 11:23:09原创8073

    1.说明

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

    2.语法

    1

    class long(x, base=10)

    3.参数

    x -- 字符串或数字。

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

    4.返回值

    返回长整型数。

    5.实例

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

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


    专题推荐:long函数
    上一篇:locals函数在python中使用 下一篇:python的shutil模块有何用法?

    相关文章推荐

    • postgresql错误不良的类型值:long解决方法

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网