Skip to main content

GetSeverity

汇总

按索引获取指定消息的严重性代码(0、1 和 2)。

语法

GetSeverity(index)

参数 说明 数据类型

index

Numeric index position of the message in the stack.

Integer

返回值

数据类型 说明

Integer

消息的严重性代码:

  • 0—消息

  • 1—警告

  • 2—错误

代码示例

GetSeverity 示例

返回各个地理处理工具消息的严重性代码和消息。

import arcpy

in_featureclass = arcpy.GetParameterAsText(0)
out_featureclass = arcpy.GetParameterAsText(1)

# Run the CopyFeatures tool. If it fails, print out the
# severity and message for each message.
try:
    arcpy.management.CopyFeatures(in_featureclass, out_featureclass)
except arcpy.ExecuteError:
    for i in xrange(0, arcpy.GetMessageCount()):
        print('{0}: {1}'.format(arcpy.GetSeverity(i),
                                arcpy.GetMessage(i)))