我正在使用Python
来处理HTML
文件。我将dataframes
导出为HTML
文件,并生成了一个可点击的目录。当我单击目录中的链接时,只有一个问题,颜色会发生变化。有没有办法让它不会发生这种情况?
html = "</head> <body> <h1>Data records</h1> <h2>From February 2019 to January 2020</h2> </body></html>"
for link, names in zip(sorted(df, key=lambda x: int(x.split('-')[0])), data_list):
html += '<a href="%s">%s</a><br>' % (link, names)
with open("test.html", "w") as f:
f.write(html)
您是否尝试过在HTML输出中添加CSS标签? 例如:
html = "<style type='text/css'>a:visited{color:black;}</style></head><body> <h1>Data records</h1> <h2>From February 2019 to January 2020</h2> </body></html>"