####################### import arcpy from arcpy import env import os import sys import time ############### ################################## fc= arcpy.GetParameterAsText(0) fieldname= arcpy.GetParameterAsText(1) shapeName = arcpy.Describe(fc).shapeFieldName rows = arcpy.UpdateCursor(fc) start = time.clock() i=1; ######################################### ## for row in rows: feat = row.getValue(shapeName) row.setValue(fieldname,feat.area) #arcpy.AddMessage("No:"+str(i)+":"+str(feat.area)) rows.updateRow(row) i=i+1; del row del rows elapsed = (time.clock() - start) arcpy.AddMessage("Time used:"+str(elapsed)+","+str(i))
第二种
def SearchCursor(): starttime = datetime.datetime.now() cursor = arcpy.SearchCursor(inTable) for row in cursor: v=row.getValue(inField) #arcpy.AddMessage("i:"+str(i)+",v="+v) #i=i+1 del cursor endtime = datetime.datetime.now() arcpy.AddMessage("时间:"+str((endtime - starttime).microseconds/1000)+"毫秒")