GetParameterAsText

摘要

按照参数在参数列表中的索引位置以文本字符串的形式获取指定参数。

说明

无论参数的数据类型是什么,所有值都将作为字符串返回;要将参数用作 ArcPy 或 Python 对象,请参阅 GetParameter

语法

GetParameterAsText (index)
参数说明数据类型
index

参数列表中参数的数值位置。

Integer
返回值
数据类型说明
String

以字符串形式返回的指定参数值。

代码示例

GetParameterAsText 示例

以文本字符串形式获取指定参数。

import os
import arcpy
# Set the input workspace, get the feature class name to copy
#  and the output location.
arcpy.env.workspace = arcpy.GetParameterAsText(0)
in_featureclass = arcpy.GetParameterAsText(1)
out_workspace = arcpy.GetParameterAsText(2)
out_featureclass = os.path.join(out_workspace,
                                os.path.basename(in_featureclass))
# Copy feature class to output location
arcpy.CopyFeatures_management(in_featureclass, out_featureclass)

相关主题