关于arcpy中的Cursor,for循环问题
MyDbf=ur'@.dbf' Navi=ur'@.shp' MyCurs=arcpy.UpdateCursor(MyDbf)#第一个指针
#NaviCurs=arcpy.SearchCursor(Navi)#如果将第二个指针放在这里,则第一遍到头后,指针就到底了,因此,要将指针放在第一个循环内部
print( time.strftime('%H:%M:%S',time.localtime()))
for MyCur in MyCurs:
Leven=100
NaviCurs=arcpy.SearchCursor(Navi)#嵌套循环的指针,应该放在这里
for NaviCur in NaviCurs:
MyName=MyCur.rname
leven=int(Levenshtein.levenshtein_distance(MyName,NaviCur.name))
if leven<Leven:
print "Myname: '%s' NaviName: %s" % ( MyName, NaviCur.name )
print(leven,Levenshtein.levenshtein(NaviCur.name,MyName))
Leven=leven
MyCur.Navi_name=NaviCur.name
MyCur.Leven=leven
MyCurs.updateRow(MyCur)
print( time.strftime('%H:%M:%S',time.localtime()))
转载自:https://blog.csdn.net/haichao062/article/details/8077950