标签:
1.try…except…else
try: fn = open("aa.txt","r") fn.write("这是一个测试文件") except Exception as e: print "错误提示",e.message else: print "写入内容成功" fn.close()
2.try…finally
try: fn = open("aa.txt","r") fn.write("这是一个测试文件") except Exception as e: print "错误提示",e.message finally: print "我都会执行" fn.close()
标签:
原文地址:http://www.cnblogs.com/2star/p/5572393.html