码迷,mamicode.com
首页 > 其他好文 > 详细

面向对像(9day)

时间:2017-10-11 11:12:00      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:其他   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

 

面向对像(9day)

标签:其他   style   sea   错误   nbsp   .com   day   for   dfa   

原文地址:http://www.cnblogs.com/wanchenxi/p/7648741.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!