我必须写一个程序来删除形式的所有表达式<word>
和</word>
其中字是任何字母序列(小写和大写)和 取出形式的所有表达式<word ..... >
和</word>
其中字是与以前一样。例如,删除<a href=”wwang3.htm” class=”c l”>
移除所有<word>标签
直到现在我的代码看起来是这样的:
def remove_1(file_location):
""""""
import re
file_variable = open(file_location)
lines = file_variable.read()
p = re.findall('<.*?>', lines)
print p
substitution = re.compile('<.*?>')
print substitution.subn(' ', p)
我得到一个指向它说,我期待一个字符串或运行程序时缓冲print.substitution.subn(' ', p)
错误。任何帮助是极大的赞赏。