def oneReplace(mystr,Findstr,Repstr): #Findstr=Findstr.decode('utf-8').encode('gb18030') idx=mystr.find(Findstr) strlen=len(Findstr.decode('utf-8')) arcpy.AddMessage("idx:"+str(idx)+":"+Findstr+"长度:"+str(strlen)) if idx<0: return mystr return mystr[0:idx]+Repstr+mystr[idx+strlen:]