脚本中shp文件在arcgis10.1下可以访问。在10.3下貌似不行

arcgis10.1下可以运行。在10.3下不行

 1 import arcpy,os
 2 
 3 # input data 
 4 input_layer = r'D:\test03\shp\all.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:\test03\shp    #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]

 

posted on 2017-12-04 16:11  太阳花太阳花  阅读(387)  评论(0编辑  收藏  举报