分享

python 笔记

 海漩涡 2014-05-24

1.python类中不支持函数重载

2.子类总是覆盖父类的方法,甚者参数列表不同也能覆盖

3.捕捉文件IO异常
try:
fsock = open("/notthere")
except IOError:
print "The file does not exist,exiting gracefully"
print "The line will always print"

4.常见异常
#no dictionray key:    KeyError

#no list value:             ValueError

#no function:              AttributeError

#no variable:             NameError

#no tran data type:  TypeError 

#no module:             ImportError

5.尝试某种操作,操作某个变量,方法,或导入模块
try:
print tanxiaohai
except NameError:
print "the value does not exist"
else:
print "the value exist"
print "always printf"

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多