Skip to main content

ListFields

Краткая информация

Возвращает список полей в классе пространственных объектов, шейп-файле или таблице в выбранном наборе данных. Возвращаемый список Python может быть ограничен с помощью критерия поиска для имени или типа поля, и будет содержать объекты Field.

Синтаксис

ListFields(dataset, {wild_card}, {field_type})

Параметр Объяснение Тип данных

dataset

The specified feature class or table with the fields to be returned.

String

wild_card

Позволяет ограничивать список возвращаемых результатов. Если значение не задано, будут возвращены все значения. Групповой символ не чувствителен к регистру.

Символ

Описание

Пример

*

Представляет ноль или больше символов.

Te* находит Теннесси и Техас.

(Значение по умолчанию — None)

*

field_type

Specifies the field type that will be returned.

  • All— All field types are returned. This is the default.

  • Blob—Fields of Blob type are returned.

  • BigInteger—Fields of Big Integer type are returned.

  • Date—Fields of Date type are returned.

  • DateOnly—Fields of Date Only type are returned.

  • Double—Fields of Double type are returned.

  • Geometry—Fields of Geometry type are returned.

  • GlobalID—Fields of Global ID type are returned.

  • Guid—Fields of GUID type are returned.

  • Integer—Fields of Integer type are returned.

  • OID—Fields of Object ID type are returned.

  • Raster—Fields of Raster type are returned.

  • Single—Fields of Single type are returned.

  • SmallInteger—Fields of Small Integer type are returned.

  • String—Fields of String type are returned.

  • TimeOnly—Fields of Time Only type are returned.

  • TimestampOffset—Fields of Timestamp Offset type are returned.

(Значение по умолчанию — All)

String

Возвращаемое значение

Тип данных Объяснение

Field

Будет возвращен список, содержащий объекты Field.

Пример кода

Пример ListFields

Создает список свойств полей.

import arcpy

# For each field in the Hospitals feature class, print
# the field name, type, and length.
fields = arcpy.ListFields("c:/data/municipal.gdb/hospitals")

for field in fields:
    print(f"{field.name} has a type of {field.type} with a length of {field.length}")
Пример ListFields 2

Создает список имен полей.

import arcpy

featureclass = "c:/data/municipal.gdb/hospitals"
field_names = [f.name for f in arcpy.ListFields(featureclass)]