
异常
文章平均质量分 63
妙舞汉宫人
这个作者很懒,什么都没留下…
展开
-
捕捉异常(1)
try: 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!" Enter the first number:10 Ent转载 2016-11-08 21:51:43 · 219 阅读 · 0 评论 -
捕捉异常(2)
class MuffledCalculator: muffled=False def calc(self,expr): try: return eval(expr) except ZeroDivisionError: if self.muffled: print 'Div转载 2016-11-08 22:01:41 · 259 阅读 · 0 评论 -
捕捉异常(3)
while True: try: x=input('Enter the first number:') y=input('Enter the second number:') value=x/y print 'x/y is ',value except: print "Invalid input.Ple转载 2016-11-08 22:12:00 · 243 阅读 · 0 评论