欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python 實(shí)現(xiàn)向word(docx)中輸出

 更新時(shí)間:2020年02月13日 15:28:09   作者:程序圓圓圓  
今天小編就為大家分享一篇Python 實(shí)現(xiàn)向word(docx)中輸出,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

安裝python-docx

pip install python-docx

如果python2安裝后不能使用(找不到包),建議直接使用python3,安裝代碼如下

pip3 install python-docx

from docx import Document
from docx.shared import Pt
 
# 簡單的打開word,輸入數(shù)據(jù),關(guān)閉word
document = Document()
# 向word里增加段落
document.add_paragraph('hello')
document.save('test.docx')
 
 
# 在一個(gè)段落中增加文字
document = Document()
paragraph = document.add_paragraph('Normal text, ')
# 增加文字
paragraph.add_run('add text')
 
# 設(shè)置word字體大小
style = document.styles['Normal']
font = style.font
font.size = Pt(10)
document.save('test.docx')

以上這篇Python 實(shí)現(xiàn)向word(docx)中輸出就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論