while True: try: number = float(input("请输入一个数字:")) # 强制转换输入的值为float类型 break except ValueError: print("输入内容不是数字,请重新输入") print("您输入的数字是:", number)