用 Python 读/写 MS Word 文件 [英] Reading/Writing MS Word files in Python

查看:22
本文介绍了用 Python 读/写 MS Word 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不使用 COM 对象的情况下在 Python 中读取和写入 Word(2003 和 2007)文件?
我知道我可以:

Is it possible to read and write Word (2003 and 2007) files in Python without using a COM object?
I know that I can:

f = open('c:file.doc', "w")
f.write(text)
f.close()

但 Word 会将其作为 HTML 文件而不是本机 .doc 文件读取.

but Word will read it as an HTML file not a native .doc file.

推荐答案

我会研究 IronPython可以访问 windows/office API,因为它在 .NET 运行时上运行.

I'd look into IronPython which intrinsically has access to windows/office APIs because it runs on .NET runtime.

这篇关于用 Python 读/写 MS Word 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆