已解决
Word docx转html和markdown
来自网友在路上 152852提问 提问时间:2023-10-26 05:16:23阅读次数: 52
最佳答案 问答题库528位专家为你答疑解惑
Pypandoc使用pandoc来进行各种文本格式的转换。
安装
# 不带pandoc执行库
pip install pypandoc# 自带pandoc
pip install pypandoc_binary
使用
import pypandoc# convert all markdown files in a chapters/ subdirectory.
pypandoc.convert_file('chapters/*.md', 'docx', outputfile="somefile.docx")# convert all markdown files in the book1 and book2 directories.
pypandoc.convert_file(['book1/*.md', 'book2/*.md'], 'docx', outputfile="somefile.docx")# convert the front from another drive, and all markdown files in the chapter directory.
pypandoc.convert_file(['D:/book_front.md', 'book2/*.md'], 'docx', outputfile="somefile.docx")
支持pathlib
import pypandoc
from pathlib import Path# single file
input = Path('somefile.md')
output = input.with_suffix('.docx')
pypandoc.convert_file(input, 'docx', outputfile=output)# convert all markdown files in a chapters/ subdirectory.
pypandoc.convert_file(Path('chapters').glob('*.md'), 'docx', outputfile="somefile.docx")# convert all markdown files in the book1 and book2 directories.
pypandoc.convert_file([*Path('book1').glob('*.md'), *Path('book2').glob('*.md')], 'docx', outputfile="somefile.docx")
# pathlib globs must be unpacked if they are inside lists.
参考
https://pypi.org/project/pypandoc/
https://pandoc.org/help.html
https://www.strerr.com/cn/word2html.html
https://zhuanlan.zhihu.com/p/30891168
https://pypi.org/project/pandoc/
查看全文
99%的人还看了
相似问题
- 关于Unity自带的保存简单且持久化数据PlayerPrefs类的使用
- EI论文程序:Adaboost-BP神经网络的回归预测算法,可作为深度学习对比预测模型,丰富实验内容,自带数据集,直接运行!
- PHP网站源码 知识付费分站代理自助下单系统 自带多款模板
- IOS自带的OCR识别功能
- 使用ffmpeg调用电脑自带的摄像头和扬声器录制音视频
- .NET Framework中自带的泛型委托Action
- .NET Framework中自带的泛型委托Func
- OneNote Win10自带的宝藏笔记工具
- 善用exchange server自带的反垃圾邮件功能过滤垃圾邮件
- unity 通过Andriod arr 访问 手机自带的浏览器
猜你感兴趣
版权申明
本文"Word docx转html和markdown":http://eshow365.cn/6-24809-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!
- 上一篇: 若依微服务上传图片文件代理配置
- 下一篇: 15、Python -- 阶段总结:变量与流程控制