arcgis10.1下可以运行。在10.3下不行
1 import arcpy,os 2 3 # input data 4 input_layer = r'D: est03shpall.shp' 5 split_field = r'NAME' 6 7 # 8 with arcpy.da.SearchCursor(input_layer, [split_field]) as cursor: 9 for row in cursor: 10 print row[0]
在10.3下
1 import arcpy,os 2 3 # input data 4 arcpy.en.workspace=r'D: est03shp #10.3下存放shp的文件夹设为工作目录才行 5 input_layer = 'all.shp' 6 split_field = r'NAME' 7 8 # 9 with arcpy.da.SearchCursor(input_layer, [split_field]) as cursor: 10 for row in cursor: 11 print row[0]