ListWorkspaces

Synthèse

Returns a list of workspaces in the current workspace.

Discussion

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

Syntaxe

ListWorkspaces ({wild_card}, {workspace_type})
ParamètreExplicationType de données
wild_card

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

SymbolDescriptionExample

*

Represents zero or more characters.

Te* finds Tennessee and Texas.

String
workspace_type

The workspace type that will limit the results returned.

  • CoverageCoverage workspaces will be returned.
  • FileGDBFile geodatabases (.gdb) will be returned.
  • FolderShapefile workspaces will be returned.
  • SDEEnterprise databases (.sde) will be returned.
  • SQLiteSQLite databases (.sqlite, .gpkg) will be returned.
  • AllAll workspaces will be returned. This is the default.

(La valeur par défaut est All)

String
Valeur renvoyée
Type de donnéesExplication
String

The list containing workspace names that is returned from the function, limited by the wild_card and workspace_type arguments.

Exemple de code

ListWorkspaces example

Compact all file geodatabases in the 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.management.Compact(workspace)

Rubriques connexes