markdown格式字串转html格式字串

参考:https://www.jianshu.com/p/0eff6cba1b7f

 

操作:

1、安装python支持包

pip install mkdocs       #  含markdown包

或者只安装markdown

pip install markdown

 

 2、代码

 1 from markdown.core import markdown
 2 
 3 if __name__ == '__main__':
 4     mdtext5 = """# Welcome to MkDocs
 5 
 6 For full documentation visit [mkdocs.org](https://www.mkdocs.org).
 7 
 8 ## Commands
 9 
10 * `mkdocs new [dir-name]` - Create a new project.
11 * `mkdocs serve` - Start the live-reloading docs server.
12 * `mkdocs build` - Build the documentation site.
13     
14 """
15     r = markdown(mdtext5, tab_length=4)
16     print(r)

 

3、输出:

 

posted @ 2019-07-03 15:27  安迪9468  阅读(822)  评论(0编辑  收藏  举报