0

I've been trying to align my text in a word document using python but just can't seem to fight out how. this is my code: `

import os 

my_text="Awesome words"
my_doc = os.path.join(os.getcwd(),'file.docx')
open(my_doc,'wb').write(my_text.encode('utf8'))

` Here's the output I'm getting

enter image description here

But here's what I want it to look like

enter image description here

tried

`


import os

my_text="Awesome words"
my_doc = os.path.join(os.getcwd(),'file.docx')
open(my_doc,'wb').write(my_text.encode('utf8'))

`

expected

enter image description here

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 05 '22 at 11:33
  • check out this library/module for handling '''docx''' files editing https://python-docx.readthedocs.io/en/latest/ – Hannon qaoud Nov 05 '22 at 11:42
  • I cannot see any part of your code which involves any type of alignment. However, this might answer your question: https://stackoverflow.com/questions/24031011/python-docx-library-text-align – ScottC Nov 05 '22 at 11:48

0 Answers0