我正在尝试在Python-markdown的帮助下使用Markdown语法将表呈现为HTML:https : //python-markdown.github.io/
我尝试了此处提供的示例:https : //python-markdown.github.io/extensions/tables/
from markdown import markdown
s = """
First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell
"""
html = markdown(s)
print(html)
Run Code Online (Sandbox Code Playgroud)
但是我得到的结果是:
<p>First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell</p>
Run Code Online (Sandbox Code Playgroud)
怎么了?
由于表是扩展名,因此您需要将其名称传递给markdown.markdown:
html = markdown(s, extensions=['tables'])
https://python-markdown.github.io/extensions/
| 归档时间: |
|
| 查看次数: |
715 次 |
| 最近记录: |