Skip To Content

ListWorkspaces

Resumen

Lists all of the workspaces within the set workspace. Search conditions can be specified for the workspace name and workspace type to limit the list that is returned.

Debate

The workspace environment must be set first before using several of the List functions, including ListDatasets, ListFeatureClasses, ListFiles, ListRasters, ListTables, and ListWorkspaces.

Sintaxis

ListWorkspaces ({wild_card}, {workspace_type})
ParámetroExplicaciónTipo de datos
wild_card

The wild_card limits the results returned. If no wild_card is specified, all values are returned.

String
workspace_type

The workspace type to limit the results returned by the wild card argument. There are six possible workspace types:

  • AccessOnly personal geodatabases will be selected.
  • CoverageOnly coverage workspaces will be selected.
  • FileGDBOnly file geodatabases will be selected.
  • FolderOnly shapefile workspaces will be selected.
  • SDEOnly enterprise databases will be selected.
  • AllAll workspaces will be selected. This is the default.

(El valor predeterminado es All)

String
Valor de retorno
Tipo de datosExplicación
String

The list containing workspace names is returned from the function, limited by the wild card and workspace type arguments.

Muestra de código

ListWorkspaces example

Compact all File Geodatabases in workspace.

import arcpy

arcpy.env.workspace = "c:/data"

# List all file geodatabases in the current workspace
workspaces = arcpy.ListWorkspaces("*", "FileGDB")

for workspace in workspaces:
    # Compact each geodatabase
    arcpy.Compact_management(workspace)

Temas relacionados