1、
mdbs = arcpy.ListWorkspaces("*","Access")
2、
FeatureClasses = arcpy.ListFeatureClasses()
3、
Fields = arcpy.ListFields(FeatureClass)
4、
cursor = arcpy.da.SearchCursor(FeatureClass, 'ELEV')
注意:工作空间的转换
import arcpy
from arcpy import env
import os
#input = r"E: estMDB"
input = arcpy.GetParameterAsText(0)
env.workspace = input
mdbs = arcpy.ListWorkspaces("*","Access")
for mdb in mdbs:
#a = ""
cout = 0
mdbname = mdb[-14:-4]
#print mdbname
env.workspace=mdb
FeatureClasses = arcpy.ListFeatureClasses()
for FeatureClass in FeatureClasses:
if "TERP" in FeatureClass:
#print FeatureClass
Fields = arcpy.ListFields(FeatureClass)
for Field in Fields:
fieldname = Field.name
#print fieldname
if "ELEV" in fieldname:
cursor = arcpy.da.SearchCursor(FeatureClass, 'ELEV')
for row in cursor:
#print(row)
if row[0] == 0:
#a = mdbname
cout = cout+1
if cout > 0:
arcpy.AddMessage(mdbname+" "+"dgx Elev have 0 problem!")
textpath = input+os.sep+"text.txt"
f = open(textpath,"a")
f.write(mdbname+'
')
f.close()
# print cout
# f = open("E:/test/text.txt","a")
#f.write(a+'
')
#f.close()