ListWorkspaces (arcpy)
Récapitulatif
Lists all of the workspaces within the set workspace. Search conditions can be specified for the workspace name and workspace type to limit the Python List that is returned.
Discussion
The workspace environment must be set first before using several of the List functions, including ListDatasets, ListFeatureClasses, ListFiles, ListRasters, ListTables, and ListWorkspaces.
Syntaxe
Paramètre | Explication | Type de données |
wild_card |
Un caractère générique limite les résultats renvoyés. Si aucun caractère générique n'est spécifié, toutes les valeurs sont renvoyées. | String |
workspace_type |
The workspace type to limit the results returned by the wild card argument. There are six possible workspace types:
(La valeur par défaut est All) | String |
Type de données | Explication |
String |
The Python List containing workspace names is returned from the function, limited by the wild card and workspace type arguments. |
Exemple de code
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)