我有以下函数,它应该读取.html
文件并搜索<input>
标签,并将<input type='hidden'>
标签注入到要显示在页面中的字符串中。但是,该条件永远不会满足:(例如,该if
语句永远不会执行。)我的正则表达式有什么问题?
def print_choose( params, name ):
filename = path + name
f = open( filename, 'r' )
records = f.readlines()
print "Content-Type: text/html"
print
page = ""
flag = True
for record in records:
if re.match( '<input*', str(record) ) != None:
print record
page += record
page += "<input type='hidden' name='pagename' value='psychology' />"
else:
page += record
print page
谢谢