我正在Google App Engine上构建一个博客。我想将我的博文中的一些关键字转换为链接,就像您在许多WordPress博客中看到的一样。Python:链接关键字
这里是一个WP插件,做同样的事情:http://wordpress.org/extend/plugins/blog-mechanics-keyword-link-plugin-v01/
一个插件,允许你定义关键字/链接对。关键字会自动链接到您的每个帖子中。
我认为这不仅仅是一个简单的Python替换。我正在处理的是HTML代码。有时可能会非常复杂。
以下面的代码片段为例。我想这个词example
CONVER到链接到http://example.com
:
Here is an example link:<a href="http://example.com">example.com</a>
通过一个简单的Python替换功能将取代example
与<a href="http://example.com">example</a>
,它会输出:
Here is an <a href="http://example.com">example</a> link:<a href="http://<a href="http://example.com">example</a>.com"><a href="http://example.com">example</a>.com</a>
,但我想:
Here is an <a href="http://example.com">example</a> link:<a href="http://example.com">example.com</a>
是否有任何Python插件能够做到这一点?非常感谢!
“一个简单的Python替换函数” - 向我们展示您的代码。 –
@罗曼呃,'my_string.replace(...)'? –