FieldExists

时间:2023-12-09 22:51:19
import arcpy
import os
import sys
def FieldExists(TableName,FieldName):
desc = arcpy.Describe(TableName)
for field in desc.fields:
if field.Name.upper() ==FieldName:
return True
break
return False
TableName= arcpy.GetParameterAsText(0) #第一个输入参数
FieldName = arcpy.GetParameterAsText(1) #第二个输入参数
FieldName=FieldName.upper()
b=FieldExists(TableName,FieldName)
arcpy.AddMessage("TableName:"+TableName+",FieldName:"+FieldName+","+str(b))
arcpy.SetParameter(2, b) #输出参数是第三个

  

相关文章