欢迎访问 如意编程网!

如意编程网

当前位置: 首页 > 前端技术 > HTML >内容正文

HTML

html文件转换成excel

发布时间:2022/11/16 HTML 23 老码农
如意编程网 收集整理的这篇文章主要介绍了 html文件转换成excel 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
path_html = str(path_f)  # 原来的html文件
file_name = str(os.path.basename(path_f)).split('.')[0]
new_excel_path = os.getcwd() + '\\' + file_name
io = str(new_excel_path + '.xlsx')  # 新的excel文件
new_io = io
# pandas html转excel
# f = open(path_html, 'r', encoding='utf-8')
f = open(path_html, 'r', encoding='GB2312')
# f = open(path_html, 'r', encoding='GBK')
html = f.read()
df = pd.read_html(html)
bb = pd.ExcelWriter(io, dtype=str)
df[0].to_excel(bb)
bb.close()

 

总结

以上是如意编程网为你收集整理的html文件转换成excel的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得如意编程网网站内容还不错,欢迎将如意编程网推荐给好友。