GetSeverity (arcpy)

摘要

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

语法

GetSeverity (index)
参数说明数据类型
index

Numeric index position of the message in the stack.

Integer
返回值
数据类型说明
Integer

消息的严重性代码:

  • 0message
  • 1警告
  • 2错误

代码实例

GetSeverity 示例

返回指定消息的严重性代码。

import arcpy

inFeatureClass = arcpy.GetParameterAsText(0)
outFeatureClass = arcpy.GetParameterAsText(1)

# Run the CopyFeatures Tool.  If it fails, print out the error messages
#
try:
    arcpy.CopyFeatures_management(inFeatureClass, outFeatureClass)
except:
    messageIndex = 0
    # Loop through the messages and check severity level
    #
    while messageIndex < arcpy.GetMessageCount:
        if arcpy.GetSeverity(messageIndex) == 2:
            # Print the error message
            #
            print arcpy.GetMessage(messageIndex)

        messageIndex += 1

相关主题

9/15/2013