Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the way Python3 reads Word files?

Shulou Source: shulou.com Published: 2022-06-02 17:33:10 09月13日 Update

This article mainly introduces "what is the way Python3 reads Word files". In daily operation, I believe that many people have doubts about the way Python3 reads Word files. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what is the way Python3 reads Word files?" Next, please follow the editor to study!

Install docx

Pip install docx

When finished, import: import docx

Found and reported error: ModuleNotFoundError: No module named 'exceptions'

It is said that there is no exceptions module, because Python3 has cancelled this module, and PendingDeprecationWarning is built-in

It can be used directly, so we go directly to the file (this depends on the path shown in your error report):

D:\ ProgramFiles\ Anaconda3\ lib\ site-packages\ docx.py

Just comment out the from exceptions import PendingDeprecationWarning

Sample code:

Import docxdef get_docx (file_name): d = docx.opendocx (file_name) doc = docx.getdocumenttext (d) return docdoc = get_docx ('tt.docx') print (doc) # output number of lines: 1075for d in doc [: 5]: print (d) # print the first 5 lines' 'output: 1. Tonifying agent 1. Sijunzi decoction neutralizes meaning, ginseng Poria cocos and licorice is named Liujun with Xia Chen, dispelling phlegm and replenishing yang deficiency bait except Pinellia ternata name Or add flavor to the stomach to make it cold.

At this point, the study on "what is the way Python3 reads Word files" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Files methods learning four gentlemen's soup more modules help output practical next code Pinellia ternata finished articles methods comments theory licorice knowledge examples Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB OPPO Reno Shulou Information NVidia Huawei