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()

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM