external.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:pyabc 作者: neuralyzer 项目源码 文件源码
def display_source_ipython(self):
        """
        Convenience method to print the loaded source file
        as syntax highlighted HTML within IPython.
        """
        from pygments import highlight
        from pygments.lexers import SLexer

        from pygments.formatters import HtmlFormatter
        import IPython.display as display

        with open(self.source_file) as f:
            code = f.read()

        formatter = HtmlFormatter()
        return display.HTML('<style type="text/css">{}</style>{}'.format(
            formatter.get_style_defs('.highlight'),
            highlight(code, SLexer(), formatter)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号