https://blog.csdn.net/red_stone1/article/details/73380517转为markdown那里,md参数要改为markdown
一、安装依赖 pip install html2text 代码实现 importosimportshutilimporthtml2textdefconvert_html2md(src_html, target_md):#'''html转md'''withopen(src_html,'r',encoding='utf-8')asf: html = f.read() markdown = html2text.html2text(html)withopen(target_md,'w',encoding='utf-8')asf: ...
importtomd reload(sys) sys.setdefaultencoding('utf8')# 设置默认编码格式为'utf-8' save_file='/Library/temp/markdown.md' defrun(): html=getHtml() printhtml mdTxt=tomd.Tomd(html).markdown print'markdown :{}'.format(mdTxt) createFile(mdTxt) defcreateFile(mdTxt): print'系统默认编码:...
将库引用(导入库)添加到您的Python项目。. 在Python打开源HTML文件。. 调用save()方法,传递带有MD扩展名的输出文件名。. HTML转换的结果MD 。. Python库将HTML转换为MD 我们在PyPi存储库中托管我们的 Python 请按照有关如何 "Aspose.Words for Python via .NET" 安装到您的开发人员环境的分步说明进行操作。