Field
汇总
Field 对象表示表格中的一列。
讨论
Field 属性可通过 ListFields 和 Describe 函数访问。
更新字段属性只会更新 Field 对象;不会对表或要素类中的实际字段进行任何更改。
语法
Field()
属性
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
aliasName (读取和写入) |
字段的别名。 |
String |
|
baseName (读取和写入) |
非限定字段名称。 |
String |
|
defaultValue (读取和写入) |
字段的默认值。 |
Variant |
|
domain (读取和写入) |
关联域名称。 |
String |
|
editable (读取和写入) |
指定字段是否可以编辑。 |
Boolean |
|
isNullable (读取和写入) |
指定该字段是否可包含空值。 |
Boolean |
|
length (读取和写入) |
字段长度。 |
Integer |
|
name (读取和写入) |
字段的名称。 |
String |
|
precision (读取和写入) |
字段值的精度。 对于日期类型的字段,精度可以是 0 或 1。
|
Integer |
|
required (读取和写入) |
指定该字段是否为必填字段。 无法删除必填字段。 |
Boolean |
|
scale (读取和写入) |
字段比例。 |
Integer |
|
type (读取和写入) |
指定字段类型。
注:
|
String |
代码示例
显示指定要素类的字段属性。
import arcpy
feature_class = "c:/data/counties.shp"
# Create a list of fields using the ListFields function
fields = arcpy.ListFields(feature_class)
# Iterate through the list of fields
for field in fields:
# Print field properties
print("Field: {0}".format(field.name))
print("Alias: {0}".format(field.aliasName))
print("Type: {0}".format(field.type))
print("Is Editable: {0}".format(field.editable))
print("Required: {0}".format(field.required))
print("Scale: {0}".format(field.scale))
print("Precision: {0}".format(field.precision))