DAY_3

2024-08-28 23:22:26 浏览数 (1)

⽂件和异常

导入PATHLIB 库, 读取文件和存储数据

异常( exception )

exception 导致程序停止, 如果异常被捕捉, 程序将继续

while True:

num_1 = input()

if num_1 == 'q':

break

num_2 = input()

if num_2 == 'q':

break

try:

answer = int(num_1) int(num_2)

except ValueError as e:

print(e)

else:

print(answer)

0 人点赞