清除空格

import sys 
reload(sys) 
sys.setdefaultencoding("utf-8")
import arcpy,os
arcpy.env.workspace = arcpy.GetParameterAsText(0)
ResultData =arcpy.GetParameterAsText(1)
Features = arcpy.ListFeatureClasses()
arcpy.AddMessage("{0}".format("Start clearing"))
for Feature in Features:
    OutCopyFeature = os.path.join(ResultData, os.path.basename(Feature))    
    outID = OutCopyFeature
    outNCHN = outID
    outNENG = outNCHN
    outYEAR = outNENG
    outFLAGP = outYEAR
    outFLAGN = outFLAGP
    outPERIOD = outFLAGN
    arcpy.CopyFeatures_management(Feature, OutCopyFeature, "", "0", "0", "0")
    arcpy.CalculateField_management(OutCopyFeature, "ID", "!ID!.strip()", "PYTHON_9.3", "")
    arcpy.CalculateField_management(outID, "NCHN", "!NCHN!.strip()", "PYTHON_9.3", "")
    arcpy.CalculateField_management(outNCHN, "NENG", "!NENG!.strip()", "PYTHON_9.3", "")
    arcpy.CalculateField_management(outNENG, "TYID", "!YEAR!.strip()", "PYTHON_9.3", "")
    arcpy.CalculateField_management(outYEAR, "FLAGP", "!FLAGP!.strip()", "PYTHON_9.3", "")
    arcpy.CalculateField_management(outFLAGP, "FLAGN", "!FLAGN!.strip()", "PYTHON_9.3", "")
    arcpy.CalculateField_management(outFLAGN, "PERIOD", "!PERIOD!.strip()", "PYTHON_9.3", "")
    arcpy.AddMessage("{0} : {1} clear".format("Completed",Feature.split(".")[0]))

你可能感兴趣的:(清除空格)