Get started with python word and pythonword
1. Install pywin32
Http://sourceforge.net/projects/pywin32
Find the python version suitable for you in files. As of this article, the latest version is the pywin32-219 shortcut path:
Http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/
After the installation, restart the Operating System. Otherwise, the system reports an error and the win32api cannot be found.
2. Simple use
Import win32comfrom win32com. client import Dispatch, constantswordApp = win32com. client. dispatch ('word. application ') # Run in the background, displayed, without warning wordApp. visible = TruewordApp. displayAlerts = 0 # create a new document doc = wordApp. documents. add () # insert text doc. paragraphs. last. range. text = 'Hello! '
# Save the file doc. SaveAs ('d: // say_hello.docx ')
Because the word api is used, all call methods are consistent. If you don't want to read documents on the Microsoft official website, the simplest way is to search for articles such as c # word and read them.