import arcpy import math def JZpoint(inpath, outfileshp): txtpath = outfileshp + '\\JZpointCount.txt' mm = 0 zdh = '' with open(txtpath,'w') as line: arcpy.MakeFeatureLayer_management(inpath, 'JZD') with arcpy.da.SearchCursor('JZD', ['SHAPE@', 'JZDH', 'ZDBH']) as cursorA: for curA in cursorA: zddm = curA[2] if zdh == '': zdh = zddm line.write(zddm +':') mm = 1 point1 = curA[0].lastPoint #重心 jzdh = curA[1] elif zddm == zdh: mm = mm + 1 else: zdh = zddm line.write(str(mm)+ '\n') line.write(zddm +':') mm = 1 #把最后一个点加上 line.write(str(mm)) if __name__ == '__main__': try: # 输入shp,输出界址点文本 JZpoint(arcpy.GetParameterAsText(0),arcpy.GetParameterAsText(1)) except arcpy.ExecuteError: arcpy.AddMessage(arcpy.GetMessages())