使用Markdown格式化代码单元格的输出 [英] Format output of code cell with Markdown

查看:72
本文介绍了使用Markdown格式化代码单元格的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Markdown似乎未处理Python代码单元的输出.

Output of Python code cell seems to be not processed by Markdown.

例如,在Python代码单元中,可能会有类似的内容:

For example in Python code cell there could be something like that:

print "**bold**"

输出为:**粗体**而不是粗体.有没有办法使它真正大胆?

And the output is: **bold** instead of bold. Is there a way to make it really bold?

推荐答案

要获取markdown格式的输出,可以使用显示设备的Markdown对象.类似于打印的功能可能看起来像

To get markdown formatted output, you can use the Markdown object of the display machinery. A print-like function could thus look like

from IPython.display import Markdown, display
def printmd(string):
    display(Markdown(string))
printmd('**bold**')

这篇关于使用Markdown格式化代码单元格的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆