Python判断一个变量值是否为数字数值类型

from numbers import Number
isinstance(x, Number)

下面是源代码中关于Number的描述

class Number(metaclass=ABCMeta):
    """All numbers inherit from this class.

    If you just want to check if an argument x is a number, without
    caring what kind, use isinstance(x, Number).
    """

 

posted @ 2022-12-08 18:32  赵米饭  阅读(67)  评论(0编辑  收藏  举报