I work with several maps with this text:
and i try to change the second line only into "landUse" by using this code:
import arcpy from arcpy import env env.workspace = r"G:\desktop\Project" for num, mxdname in enumerate((arcpy.ListFiles("*.mxd")),start = 1): print '\n',num,mxdname mxd = arcpy.mapping.MapDocument( r"G:\desktop\Project\\" + mxdname) for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): elm.text = elm.text.replace(u'aaa', u'landUse') mxd.save() del mxd
when i run it i get this unwanted result:
whereas i want this result:
i didn't find an answer in Changing part of text element using ArcPy?