AddFieldDelimiters

摘要

为字段名称添加字段分隔符,以将其用于 SQL 查询。

旧版本:

此为旧版本函数。 对于 ArcGIS Pro 中的 SQL 查询,不需要字段分隔符。

语法

AddFieldDelimiters (datasource, field)
参数说明数据类型
datasource

The data source used to determine the field delimiters.

String
field

The field name to which delimiters will be added. The field does not have to currently exist.

String
返回值
数据类型说明
String

分隔的字段名称。

代码示例

AddFieldDelimiters 示例
import arcpy

field_name = arcpy.GetParameterAsText(0)
arcpy.env.workspace = arcpy.GetParameterAsText(1)
in_features = arcpy.GetParameterAsText(2)
out_feat_class = arcpy.GetParameterAsText(3)
state_value = arcpy.GetParameterAsText(4)

# AddFieldDelimiters will return a field name with the proper
# field delimiters for the workspace specified.
sql_exp = """{0} = '{1}'""".format(
    arcpy.AddFieldDelimiters('c:/data', field_name),
    state_value)

# Use delimited field for Select tool SQL expression
arcpy.analysis.Select(in_features, out_feat_class, sql_exp)

相关主题