Hey everyone. I've been pouring through the internet to try to find an example to use carriage returns in a python script. (i.e. vbnewline from vb)
In my script example below I am cycling through the text elements in a series of maps and replacing any of them that contain the text "TITLE BLOCK" with a string composed of variables that read from a look up table.
As you can see I want the first variable to sit on the first line, the second to sit on the second line and so forth.
Using the /n new line function, it's supposed to return the next variable to a new line. This is not working for me. I have tried a number of different ways and I either get an error message or all the texts gets placed into the text element box, but it all sits on one line. Does anyone suggest a workaround?
Thanks, Mike
for textElement in arcpy.mapping.ListLayoutElements(mxd2, "TEXT_ELEMENT"):
if textElement.text == "TITLE BLOCK":
#print row.SITE
textElement.text = firstline + '/n' + secondline + '/n' + thirdlinea + " " + thirdlineb
www.python.org has the official documentation, look for "escape characters" within the string section Books by O'Reilly serve as good hardcopy companions to the web documents that exist.
Thanks for the input people. This was definitely a brain stump on my part. My sytax is correct except I used forward slashes instead of back slashes....so it should have been '\n' instead of '/n'
Dan, thanks for the reference. It was there, that I recognized my problem.