我正在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(...)'? –