CreateUniqueName

摘要

Creates a unique name in the specified workspace by appending a number to the input name. This number is increased until the name is unique. If no workspace is specified, the current workspace is used.

语法

CreateUniqueName (inputName, {workspace})
参数说明数据类型
inputName

The base name used to create the unique name.

String
workspace

The workspace used for creation of the unique name.

String
返回值
数据类型说明
String

The unique name with a number appended to make it unique in the workspace. The number starts at 0 and is incremented until it is unique.

代码示例

CreateUniqueName example

Creates a unique name for use with the Buffer and Clip tools.

import arcpy
from arcpy import env

# Set workspace
env.workspace = "C:/Data"

# Create a unique name for the Buffer tool's derived output.
unique_name = arcpy.CreateUniqueName("xxx.shp")

# Use unique name for Buffer Tool output dataset name
arcpy.Buffer_analysis("roads.shp", unique_name, "100 feet")

# Clip output from Buffer tool with County Boundary to obtain buffered roads in county.
arcpy.Clip_analysis(unique_name, "County.shp", "ClippedRoads.shp")

相关主题


7/10/2012