Python中not defined问题

def aa(shu=''):
while 1:
try:
hu=input (shu)
h=int(hu)
except ValueError:
print ('不是整数')
finally:
if type (h)==int:
break
else:
continue
aa()

出现了h is not defined
请各位解一下thx

函数调用的时候 需要传递参数 比如 aa(1)
或者 你在第一函数的时候 aa(shu=-1)
给一个 数字类型的,否则无法完成转换int类型

请采纳


def is_number(s):
    try:
        float(s)
        return True
    except ValueError:
        pass

    try:
        import unicodedata
        unicodedata.numeric(s)
        return True
    except (TypeError, ValueError):
        pass

    return False


def aa():
    while True:
        num = input("请输入数字")
        if is_number(num):
            print("成功输入: ", num)
        else:
            print("输入类型不正确")


aa()