1# 运行word程序
word = wc.Dispatch("Word.Application")
# for循环
i = 0
for file in files:
try:
doc = word.Documents.Open(file) #打开word文件
doc.SaveAs("{}x".format(file), 12) #另存为后缀为".docx"的文件,其中参数12指docx文件
doc.Close() #关闭原来word文件
print(file +':转换成功')
i +=1
except:
print(file +':转换[不成功]')
files.append(file) # 若读取文件报错, 则将文件名称添加到files列表中重新读取
pass
print('转换文件%i个'%i)
# 退出word
word.Quit()
1 1 <div style="opacity:0.5;position:absolute;left:50px;width:300px;height:150px;background-color:#40B3DF"></div>
<div style="font-family:verdana;padding:20px;border-radius:10px;border:10px solid #EE872A;">
<div style="opacity:0.3;position:absolute;left:120px;width:100px;height:200px;background-color:#8AC007"></div>
<h3>Look! Styles and colors</h3>
<div style="letter-spacing:12px;">Manipulate Text</div>
<div style="color:#40B3DF;">Colors
<span style="background-color:#B4009E;color:#ffffff;">Boxes</span>
</div>
1 |