标签:htm 百度 字体 合集 http man orm run font
from docx import Document #引入docx模块
from docx.shared import Pt,RGBColor
from docx.oxml.ns import qn
import requests #Python3,引入requests库
Doc=Document()
Doc.add_heading("网站合集", level=1)
url=["https://china.com/","https://jingyan.baidu.com/","https://www.runoob.com/python3/","https://www.icourse163.org/",
"https://www.icourse163.org/client/callAppDownload.htm"]
A = ["中国", "百度经验", "菜鸟编程", "中国Mooc", "中国Mooc APP下载"]
for i in range(len(url)):
for j in range(len(A)):
if i==j:
Doc.add_heading(A[j], level=2)
r = requests.get(url[i])
r.encoding = r.apparent_encoding
Doc.add_paragraph(r.text)
for paragraph in Doc.paragraphs:
for run in paragraph.runs:
run.font.name = "宋体" # 字体
r = run._element.rPr.rFonts # 中文字体
r.set(qn(‘w:eastAsia‘), "宋体")
Doc.styles[‘Normal‘].font.name = ‘Times New Roman‘
Doc.save("F:\ypm\python学习/网站合集.docx")
为什么不能将英文的字体改成新罗马?怎么修改代码?那位大神可以指点指点呢?
标签:htm 百度 字体 合集 http man orm run font
原文地址:https://www.cnblogs.com/yangpengmin/p/13472883.html