n=0
sum = 0
while True:
    try:
        inputnumber = input(">>>>>")
        if inputnumber == "exit":
            break
        n += 1
        sum += int(inputnumber)
        print(sum)
    except :
        print("输入有误")

运行结果:

>>>>>1

1
>>>>>34
35
>>>>>35
70
>>>>>44
114
>>>>>556
670
>>>>>e
输入有误
>>>>>ertgtg
输入有误
>>>>>exit

Process finished with exit code 0