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" |
|
来自: 海漩涡 > 《python笔记》