1.python類中不支持函數(shù)重載 2.子類總是覆蓋父類的方法,甚者參數(shù)列表不同也能覆蓋 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.嘗試某種操作,操作某個變量,方法,或?qū)肽K try: print tanxiaohai except NameError: print "the value does not exist" else: print "the value exist" print "always printf" |
|
來自: 海漩渦 > 《python筆記》