Skip to main content

AddWarning

汇总

向脚本工具或 Python 工具箱工具的消息中添加警告消息(严重性为 1)。

运行工具时,可以从 地理处理 窗格、 地理处理历史记录 以及从 Python 调用工具时的消息列表中访问警告消息。

语法

AddWarning(message)

参数 说明 数据类型

message

The warning message.

String

代码示例

AddWarning 示例

向 Python 脚本工具添加警告消息。

import arcpy

fc = arcpy.GetParameterAsText(0)

# Get the count from GetCount's Result object
feature_count = int(arcpy.management.GetCount(fc).getOutput(0))

if feature_count == 0:
    arcpy.AddWarning("{0} has no features.".format(fc))
else:
    arcpy.AddMessage("{0} has {1} features.".format(fc, feature_count))