TranslateProject | Linux Chinese Translation Project | Translation library
kandi X-RAY | TranslateProject Summary
kandi X-RAY | TranslateProject Summary
Linux Chinese Translation Project
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of TranslateProject
TranslateProject Key Features
TranslateProject Examples and Code Snippets
Community Discussions
Trending Discussions on TranslateProject
QUESTION
I'm using FastAPI (not async) and python-docx library, trying to read a docx file. I'm getting an error while trying to read the docx file.
My code -
...ANSWER
Answered 2020-Oct-15 at 16:38Don't .read()
the file that is given to Document()
. Just give it the filename or you can give it an open file that has it's cursor set on offset 0. If the "file" you have is already a bytes object then you can use an io.BytesIO
"in-memory" file to give to Document()
.
The docx_file
parameter in Document(docx_file)
can be a str
file path or can be a file-like object (an open file created with open(...)
or an in-memory file created with io.BytesIO
), but it cannot be a bytes
object (what is returned by file.read()
).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install TranslateProject
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page