#coding=utf8 import arcpy import os import sys import ylpy try: a=1111111 b=0000 c=a/b except Exception as e: arcpy.AddError(e) finally: #'''不管try语句中的代码是否报错,都会执行finally分支中的代码''' #'''去完成一些连接操作的收尾工作''' arcpy.AddMessage('finally 被执行了') arcpy.AddMessage("***:{0}".format(arcpy.GetReturnCode(0))) num = arcpy.GetMessageCount() arcpy.AddWarning("{0} AddWarning".format(num)) num = arcpy.GetMessageCount() for i in range(num): arcpy.AddMessage("{0}==========={1}".format(i,arcpy.GetMessage(i))) arcpy.AddReturnMessage(i)