📜  允许将“1+2j”之类的复数视为有效数字 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:23.703000             🧑  作者: Mango

代码示例1
def is_number(n):
    is_number = True
    try:
        #      v type-casting the number here as `complex`, instead of `float`
        num = complex(n)
        is_number = num == num
    except ValueError:
        is_number = False
    return is_number