笨鸟编程-零基础入门Pyhton教程

 找回密码
 立即注册
笨鸟先学早入门,一分付出一分收获

房东烦烦烦烦烦烦烦烦烦

发布者: 夏克米


<table border="1">
    <tr>
        <th>表头1</th>
        <th>表头2</th>
    </tr>
    <tr>
        <td>李白, 打野</td>
        <td>貂蝉, 中单</td>
    </tr>
    <tr>
        <td>虞姬, 发育路</td>
        <td>阿瑶, 辅助</td>
    </tr>
</table>
# 运行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()

最新评论

Archiver|手机版|笨鸟自学网 ( 粤ICP备20019910号 )

GMT+8, 2024-9-17 03:44 , Processed in 0.041872 second(s), 18 queries .

© 2001-2020

返回顶部