ListWorkspaces (arcpy)

摘要

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.

讨论

必须先设置工作空间环境,之后才能使用多个列表函数,这些列表函数包括 ListDatasets、ListFeatureClasses、ListFiles、ListRasters、ListTables 和 ListWorkspaces。

语法

ListWorkspaces ({wild_card}, {workspace_type})
参数说明数据类型
wild_card

通配符可限制返回的结果。如果未指定任何通配符,则会返回所有值。

String
workspace_type

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

  • Access —Only personal geodatabases will be selected.
  • Coverage —Only coverage workspaces will be selected.
  • FileGDB —Only file geodatabases will be selected.
  • Folder —Only shapefile workspaces will be selected.
  • SDE —Only ArcSDE databases will be selected.
  • All —All workspaces will be selected. This is the default.

(默认值为 All)

String
返回值
数据类型说明
String

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

代码实例

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)

相关主题

9/15/2013