Sep-18-2021, 06:51 PM
hello,
i would like to change a word in a word document.
OS: linux
python 2 et 3 used to no avail
i would like to change a word in a word document.
from docx import Document document = Document('/path/word_template.docx') doc = docx.Document() VAR1 = input('FIRST_NAME: ') VAR2 = input('LAST_NAME: ') for paragraph in document.paragraphs: if 'FIRST_NAME' in paragraph.text: print paragraph.text paragraph.text = VAR1 elif 'LAST_NAME' in paragraph.text print paragraph.text paragraph.text = VAR1 doc.save('/path/word_template.docx')
Error:Traceback (most recent call last):
File "test1.py", line 1, in <module>
from docx import Document
ModuleNotFoundError: No module named 'docx'
how odd.OS: linux
python 2 et 3 used to no avail