fin_list.append("</font>") colorTexts=["black","gray","silver","white","blue","navy","teal","green","lime","aqua","yellow","red","fuchsia","olive"," purple","maroon"] for texts in colorTexts: ans=re.search("<%s>"%texts,row) if ans!=None: sl=ans.span() first=row[:sl[0]] second='<font color="%s">'%row[sl[0]+1:sl[1]-1] last=row[sl[1]:] row=first+second+last fin_list.append("</font>") こちらも正規表現を利用して、実装しています。