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