我有以下字符串迫使我的Python脚本退出:
"625 625 QUAIL DR UNIT B"
我需要删除字符串中间的多余空格,因此我尝试使用以下拆分连接脚本:
import arcgisscripting import logging logger = logging.getLogger() gp = arcgisscripting.create(9.3) gp.OverWriteOutput = True gp.Workspace = "C:\ZP4" fcs = gp.ListWorkspaces("*","Folder") for fc in fcs: print fc rows = gp.UpdateCursor(fc + "//Parcels.shp") row = rows.Next() while row: Name = row.GetValue('SIT_FULL_S').join(s.split()) print Name row.SetValue('SIT_FULL_S', Name) rows.updateRow(row) row = rows.Next() del row del rows
您的源代码和错误不匹配,错误状态为您未定义变量SIT_FULL_S。
SIT_FULL_S
我猜您想要的是:
Name = ' '.join(row.GetValue('SIT_FULL_S').split())