Exists (arcpy)

Zusammenfassung

Determines the existence of the specified data object. Tests for the existence of feature classes, tables, datasets, shapefiles, workspaces, layers, and files in the current workspace. The function returns a Boolean indicating if the element exists.

Syntax

Exists (dataset)
ParameterErläuterungDatentyp
dataset

The name, path, or both of a feature class, table, dataset, layer, shapefile, workspace, or file to be checked for existence.

String
Rückgabewert
DatentypErläuterung
Boolean

A Boolean value of True will be returned if the specified element exists.

Codebeispiel

Exists example

Check for existence of specified data object.

import arcpy

# Set the current workspace
#
arcpy.env.workspace = "c:/base/data.gdb"

# Check for existence of data before deleting
#
if arcpy.Exists("roadbuffer"):
    arcpy.Delete_management("roadbuffer")

Verwandte Themen

4/26/2014