ListEnvironments (arcpy)

摘要

ListEnvironments 函数可返回地理处理环境名称的 Python 列表。

语法

ListEnvironments ({wild_card})
参数说明数据类型
wild_card

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

# A wild_card of "*workspace" will return a list including the 
#   workspace and scratchWorkspace environment names
arcpy.ListEnvironments("*workspace")
String
返回值
数据类型说明
String

该函数返回的 Python 列表包含了地理处理环境变量名称,并可受通配符过滤器的限制。

代码实例

ListEnvironments 示例

列出环境变量名称和当前值。

import arcpy
import string

environments = arcpy.ListEnvironments()

# Sort the environment list, disregarding capitalization
#
environments.sort(key=string.lower)

for environment in environments:
    # As the environment is passed as a variable, use Python's getattr 
    #   to evaluate the environment's value
    #
    envSetting = getattr(arcpy.env, environment)

    # Format and print each environment and its current setting
    #
    print "{0:<30}: {1}".format(environment, envSetting)

相关主题

9/15/2013