标签:str continue raise mat 变量 存在 def style close
错误
异常
1 try: 2 s = input(‘please enter two numbers separated by comma: ‘) 3 num1 = int(s.split(‘,‘)[0].strip()) 4 num2 = int(s.split(‘,‘)[1].strip()) 5 6 except (ValueError, IndexError) as err: 7 print(‘Error:{}‘.format(err)) 8 9 print(‘continue‘)
1 class MyInputError(Exception): 2 def __init__(self, value): 3 self.value = value 4 def __str__(self): 5 return("{} is invalie input".format(repr(self.value))) 6 try: 7 raise MyInputError(1) 8 except MyInputError as err: 9 print(‘Error:{}‘.format(err))
标签:str continue raise mat 变量 存在 def style close
原文地址:https://www.cnblogs.com/cxc1357/p/12700592.html