摘要
每当地理处理工具遇到错误时,都将触发 ExecuteError 异常类。
代码实例
ExecuteError 异常示例
在下面的代码中,ExecuteError 类用于专门处理任何由 CopyFeatures 导致的地理处理工具错误。
import arcpy
in_features = "c:/base/transport.gdb/roads"
try:
# Note: CopyFeatures will always fail if the input and output are
# the same feature class
arcpy.CopyFeatures_management(in_features, in_features)
except arcpy.ExecuteError:
print(arcpy.GetMessages())