Synthèse
Determines the existence of the specified data object. This function tests for the existence of various data types including feature classes, tables, datasets, shapefiles, workspaces, layers, and files. The function returns a Boolean indicating whether the element exists.
Discussion
Layers in a stand-alone script and layers in an active map can be used as input to Exists.
Syntaxe
Exists (dataset)
Paramètre | Explication | Type de données |
dataset | The path to the dataset to be checked for existence. | String |
Type de données | Explication |
Boolean | A Boolean value of True will be returned if the specified element exists. |
Exemple de code
Check for the 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")
Rubriques connexes
Vous avez un commentaire à formuler concernant cette rubrique ?