# python3 code
import re
# for example
s = '123<><here>#$%@#$%^<123>::<a class="haha" href="http://www.hello.com">haha'
print(re.sub('<[^>]*>', '', s))
# read txt and remove all <...>
with open('your.txt', 'r') as reader:
for line in reader:
line = line.strip()
print(re.sub('<[^>]*>', '', line))
大概是這樣:
使用
re.sub
把<...>
取代為空白:範例字串取代結果:
我回答過的問題: Python-QA