它将打印前20名firefox历史记录并保存到html中文件。它都会在Python3里完成。 我必须在Python2里做同样的事情。 有没有什么方法可以修改这个代码或者用别的方法来做python2。你知道吗
import platform
import os
import browserhistory as bh
def printTohtml(htmlfile):
html = "<html>\n<head></head>\n<style>p { margin-bottom:5px !important; }</style>\n<body>\n"
title = "Browser History"
html += '\n<p style = "background-color: #92a8d1 !important; color:white !important; font-size:24px !important; text-align: center !important; letter-spacing: 5px !important; ">' + title + '</p>\n'
para = '<p style = "background-color: #92a8d1 !important; color:white !important; font-size:24px !important; text-align: center !important; letter-spacing: 5px !important;">' + browserhistory1 + '</p>\n'
html += para
dict_obj = bh.get_browserhistory()
for i in range(0 ,19):
html += '<p style = "white-space: pre-line !important; line-height: 28px !important;">' + str(dict_obj['firefox'][i]) + '</p>\n'
with open(htmlfile, 'w') as f:
f.write(html + "\n</body>\n</html>")
browserhistory1 = ("Browser History")
printTohtml('firefox.html')
下面的代码应该有效
相关问题 更多 >
编程相关推荐