Closed. This question does not meet Stack Overflow guidelines 。它目前不接受答案。












想改善这个问题吗?更新问题,使其成为 Stack Overflow 的 on-topic

7年前关闭。



Improve this question




有没有办法将 Python 代码发布到博客中?

例如,是否有任何适用于 Eclipse 或 Emacs 的插件可用于将代码格式化或转换为博客的 HTML 片段?

我偶然发现了 this question 但没有提到 Python,我想知道这是否可行以及如何做。

博主有 this 在线源代码格式化程序,但我不确定它是否正确突出显示了 python 代码..

有什么想法吗?

感谢所有的好帮助。

最佳答案

你为什么不试试 pygments ?

http://pygments.org/

脚步

  • 启动你的 shell(如果你在 Windows 上,则为 cmd)
  • 运行:'easy_install pygments'并等待

  • 你可以使用这个
    pygmentize -f html -O full -o file.html file.py
    

    -O full 告诉 pygmentize 生成一个完整的 HTML 文档

    -o 告诉 pygmentize 将 HTMl 代码输出到 file.html

    关于python - 如何将python代码发布到博客?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21440221/

    10-14 16:04
    查看更多