def isnum(a): if type(eval(a)) == int or type(eval(a)) == float or type(eval(a)) == complex: return True else: return False print(isnum(input()))
因为你这样输入的话都是str类型的,可以改成s= eval(input('请输入字符串'))有帮助的话请采纳,谢谢!