def strip_ml_tags(in_text):
"""Description: Removes all HTML/XML-like tags from the input text.
Inputs: s --> string of text
Outputs: text string without the tags
# doctest unit testing framework
>>> test_text = "Keep this Text KEEP 123"
>>> strip_ml_tags(test_text)
'Keep this Text KEEP 123'
"""
s_list = list(in_text)
i,j = 0,0
while i < len(s_list):
if s_list[i] == '<':
while s_list[i] != '>':
s_list.pop(i)
# pops the right-angle bracket, too
s_list.pop(i)
else:
i=i+1
join_char=''
return join_char.join(s_list)
def bbToHtmltags(html):
pass
做留言版、討論區、BLOG、網頁相關時,時常用得到
Removes all HTML/XML-like tags from the input text.
Inputs: s --> string of text
Outputs: text string without the tags
文件說明已寫得很清楚
將網頁語法如 "Keep this Text KEEP 123"
讓程式讀取後,去除 <> 內的文字,再做輸出成如下: