Skip to main content

表属性

汇总

Describe 函数可返回表的以下属性。 还支持 数据集 属性组。 如果已对此表启用编辑者追踪,则支持 编辑者追踪 属性组。

各种类型的 Describe 对象中均存在表属性。

对于表, Describe 函数的 dataType 属性将返回值 "Table"

属性

属性 说明 数据类型

controllerMemberships

(只读)

表的 controllerMemberships 属性列表。

Object

dateAccessed

(只读)

上次在地图中访问该表的 UTC 日期。 对于要素图层,将包括更新图层符号系统。

String

dateCreated

(只读)

要素类被创建时的日期 (UTC)。

String

dateModified

(只读)

地理处理工具上次修改要素类的日期 (UTC)。

String

hasOID

(只读)

用于指定表是否包含对象 ID 字段。

Boolean

hasOID64

(只读)

用于指定表的对象 ID 字段是否为 64 位整型。 仅当 hasOID 属性返回 True 时才支持此属性。 使用 Python getattr 函数可避免 AttributeError 异常。

Boolean

OIDFieldName

(只读)

对象 ID 字段(如果存在)的名称。

String

fields

(只读)

此表的 Field 对象列表。 此属性相当于使用 ListFields 函数。

Field

indexes

(只读)

此表的 Index 对象列表。 此属性相当于使用 ListIndexes 函数。

Index

代码示例

表属性示例

如果表包含 OID 字段名称,则以下独立脚本将显示该字段名称。 然后将打印表中每个字段的名称和类型。

import arcpy

# Create a Describe object from the table.
desc = arcpy.Describe("C:/data/chesapeake.gdb/munich")

# If the table has an OID, print the OID field name
if desc.hasOID:
    print("OIDFieldName: " + desc.OIDFieldName)

# Print the names and types of all the fields in the table
for field in desc.fields:
    print("%-22s %s %s" % (field.name, ":", field.type))
    #print field.name + " = " + field.type