CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day11/ex2.py
Views: 729
1
"""
2
异常机制 - 处理程序在运行时可能发生的状态
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-03-13
7
"""
8
9
input_again = True
10
while input_again:
11
try:
12
a = int(input('a = '))
13
b = int(input('b = '))
14
print('%d / %d = %f' % (a, b, a / b))
15
input_again = False
16
except (ValueError, ZeroDivisionError) as msg:
17
print(msg)
18
19