Returns a list of fields in a feature class, shapefile, or table in a specified dataset. The returned list can be limited with search criteria for name and field type and will contain Field objects.


ListFields (dataset, {wild_card}, {field_type})
ParamètreExplicationType de données

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


Limits the results returned. If a value is not specified, all values are returned. The wildcard is not case sensitive.



Represents zero or more characters.

Te* finds Tennessee and Texas.

(La valeur par défaut est None)


Specifies the field type that will be returned.

  • All All field types are returned. This is the default.
  • BlobFields of Blob type are returned.
  • BigIntegerFields of Big Integer type are returned.
  • DateFields of Date type are returned.
  • DateOnlyFields of Date Only type are returned.
  • DoubleFields of Double type are returned.
  • GeometryFields of Geometry type are returned.
  • GlobalIDFields of Global ID type are returned.
  • GuidFields of GUID type are returned.
  • IntegerFields of Integer type are returned.
  • OIDFields of Object ID type are returned.
  • RasterFields of Raster type are returned.
  • SingleFields of Single type are returned.
  • SmallIntegerFields of Small Integer type are returned.
  • StringFields of String type are returned.
  • TimeOnlyFields of Time Only type are returned.
  • TimestampOffsetFields of Timestamp Offset type are returned.

(La valeur par défaut est All)

Valeur renvoyée
Type de donnéesExplication

A list containing Field objects is returned.

Exemple de code

ListFields example

List field properties.

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"{} has a type of {field.type} with a length of {field.length}")
ListFields example 2

Generate a list of field names.

import arcpy

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

Rubriques connexes