摘要
用于获取从之前运行的工具返回的最大严重性。
语法
GetMaxSeverity ()
数据类型 | 说明 |
Integer | 返回的严重性。
|
代码示例
根据之前运行的工具的最大严重性显示自定义消息。
import arcpy
# Set current workspace
arcpy.env.workspace = "c:/data/mydata.gdb"
try:
arcpy.analysis.Clip("Roads", "County", "Roads_Clip")
except arcpy.ExecuteError:
pass
severity = arcpy.GetMaxSeverity()
if severity == 2:
# If the tool returned an error
print(f"Error returned \n{arcpy.GetMessages(2)}")
elif severity == 1:
# If the tool returned no errors, but returned a warning
print(f"Warning returned \n{arcpy.GetMessages(1)}")
else:
# If the tool did not return an error or a warning
print(arcpy.GetMessages())