我正在尝试在 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)
但我得到的结果是:
<p>First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell</p>
怎么了?
最佳答案
由于 tables 是一个扩展,您需要将其名称传递给 markdown.markdown
:
html = markdown(s, extensions=['tables'])
关于python - 为什么表格在 Python-markdown 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53694529/