使用 Python 编辑 RTF 文件 [英] Edit RTF file using Python

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

问题描述

也许这是一个愚蠢的问题,但我不明白这一点 :)

Maybe this is a dumb question, but I don't get it so appologize :)

我有一个 RTF 文档,我想更改它.例如.有一个表格,我想复制一行并以面向对象的方式更改代码中第二行中的文本.

I have an RTF document, and I want to change it. E.g. there is a table, I want to duplicate a row and change the text in the second row in my code in an object-oriented way.

我认为 pyparsing 应该是要走的路,但我摆弄了几个小时却没有明白.我没有提供示例代码,因为我认为这都是无稽之谈:/

I think pyparsing should be the way to go, but I'm fiddling around for hours and don't get it. I'm providing no example code because it's all nonsense I think :/

我是在正确的道路上还是有更好的方法?

Am I on the right path or is there a better approach?

以前有人做过类似的事情吗?

Anyone did something like that before?

推荐答案

RTF 是带有特殊符号"的文本文档,用于创建格式.(见 - http://search.cpan.org/~sburke/RTF-Writer/lib/RTF/Cookbook.pod#RTF_Document_Structure 不过似乎 perl 有一个很好的 RTF 库),所以是的,PyParsing 是一个很好的方法.一定要学好结构再解析(我说的那个页面里面有perl代码的例子,运气好的话可以用python翻译一下)

RTFs are text documents with special "symbols" to create the formatting. (see - http://search.cpan.org/~sburke/RTF-Writer/lib/RTF/Cookbook.pod#RTF_Document_Structure It seems that perl has a good RTF library though), so yes, PyParsing is a good way to go. You have to learn the structure and then parse (there are perl code examples in the page i mentioned. If you are lucky you can translate them in python with some effort)

python 有一个基本的 RTF 模块.检查 - http://pyrtf.sourceforge.net/

There is a basic RTF module available for python. Check - http://pyrtf.sourceforge.net/

希望对你有所帮助.

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

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