标签:其他 style sea 错误 nbsp .com day for dfa
http://www.cnblogs.com/linhaifeng/articles/6232220.html
异常处理
# print(x) # int(‘asdf‘) # res1=1/0 # res2=1+‘str‘ # l=[1,2,3] # l[100] # print(‘=====‘) # print(‘=====‘) # print(‘=====‘) # print(‘=====‘) # d={‘a‘:1} # d[‘b‘] # # # print(‘111111111111‘) # print(‘111111111111‘) # print(‘111111111111‘) # print(‘111111111111‘) # x=1 # # if x > 1 # print(‘asdfsadfasdf‘) # class Foo: # x=1 # # print(Foo.x) # print(Foo.y) l=[1,2,3,4,4,5,6] # index=1000 # if len(l) > index: # print(l[index]) # def search(): # print(‘search‘) # cmd_dic={ # ‘search‘:search # } # while True: # choice=input(":>>").strip() # if choice in cmd_dic: # cmd_dic[choice]() # # try: # print(‘======‘) # print(x) # print(‘======‘) # print(‘======‘) # except KeyError as x: # print(x) # except NameError as e: # print(e) # # print(‘继续其他的事情‘) # try: # print(x) # # l=[1,2,3] # # l[1000] # # d={‘a‘:1} # # d[‘b‘] # # except KeyError: # pass # except ValueError: # pass # except Exception: # pass # s1 = ‘hello‘ # try: # int(s1) # except IndexError as e: # print(e) # # except KeyError as e: # # print(e) # # except ValueError as e: # # print(e) # #except Exception as e: # # print(e) # else: # print(‘try内代码块没有异常则执行我‘) # finally: # print(‘无论异常与否,都会执行该模块,通常是进行清理工作‘) # raise IndexError(‘asdfasfadsfasdfsadfasdf‘) # print(IndexError) # print(ValueError) # # # class EgonException(BaseException): # def __init__(self,msg): # self.msg=msg # def __str__(self): # return self.msg # # # raise EgonException(‘类型错误‘) # x=1 # y=2 # assert x == y # print(‘===>‘) # try: # l=[1,2,3] # l[100000] # except Exception: # pass # try: # for i in range(10) # print(i) # except Exception: # pass
标签:其他 style sea 错误 nbsp .com day for dfa
原文地址:http://www.cnblogs.com/wanchenxi/p/7648741.html