为什么表在Python-markdown中不起作用?

Fom*_*aut 3 python markdown

我正在尝试在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)

怎么了?

Tra*_*ion 7

由于表是扩展名,因此您需要将其名称传递给markdown.markdown

html = markdown(s, extensions=['tables'])

https://python-markdown.github.io/extensions/