下面来介绍一下它:
首先安装很简单,使用easy_install来进行安装:
easy_install pygments
安装完后我们来使用,Python的简单不会让大家失望:
from pygments.lexers import PythonLexver from pygments.formatters import HtmlFormatter from pygments import highlight formatter = HtmlFormatter(encoding='utf-8', style = 'emacs', linenos = True) code = highlight('print "hello, world"', PythonLexer(), formatter) print code
结果
'1查看更多关于编写Python脚本使得web页面上的代码高亮显示的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did88519