表属性 (arcpy)

摘要

Describe 函数将返回表的以下属性。还支持数据集属性

各种类型的 Describe 对象中均提供表属性。

属性

属性说明数据类型
hasOID
(只读)

Indicates whether the table has an ObjectID field.

Boolean
OIDFieldName
(只读)

The name of the OID field if it exists.

String
fields
(只读)

A Python list of Field objects for this table. This is the same as using the ListFields function.

Field
indexes
(只读)

A Python list of Index objects for this table. This is the same as using the ListIndexes function.

Index

代码实例

Table properties example (stand-alone script)

The following stand-alone script displays the OID field name if the table has one. It then prints the name and type for each field in the table.

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
9/15/2013