代码如下:
__author__ = 'Administrator'
try:
while True:
x = input("Enter the first number:")
y = input("Enter the second number:")
print x/y
except ZeroDivisionError:
print "The second number can't be zero!"
主要实现了一个无限循环简单的计算器,当出现ZeroDivisionError时进行提示。
学到异常这里,顺便练练之前的循环的内容