Writing text to a word document (word 2007) using the zipfile module via python
coding (python 2.7). Below if the section of code I am using to do this. I
can't figure out what character I need to use to get it to add new lines to the
zipfile.
if Count:
blurb = "\r\nINSERT TABLE HERE\r\n\r\nSA* - South America\r\nNA** - North
America\r\nCA*** - Central America"
else:
blurb = ""
further down I also have the following code (a small snippet of actual code for
clarification)
replaceText = {"TEXTBLURB" : blurb}
Right now "if Count" is true, the output in the word document looks like this:
INSERT TABLE HERE SA* - South America NA** - North America CA*** - Central
America
I want it too look like this:
INSERT TABLE HERE
SA* - South America
NA** - North America
CA*** - Central America
I have a MS Word template file called "Automated Response.docx" that has a TAG
imbedded between two paragraphs called "TEXTBLURB". Using a python script, if a
certain condition is met, I want to replace this tag with some text (see above
"blurb") that contains newlines, otherwise, don't add the text between
paragraphs. I can't figure out the python code needed to imbed newlines into
the tag.
Ideas as to how to add new lines via python coding? I tried \r, \n, \r\n,
^11 and . None worked.
--
http://mail.python.org/mailman/listinfo/python-list