Can Python be embedded in HTML like PHP and JSP?

前端 未结 5 1779
无人及你
无人及你 2020-12-14 07:47

Is there a way of writing Python embedded in HTML like I do with PHP or JSP?

相关标签:
5条回答
  • 2020-12-14 08:26

    Use a template engine, such as:

    • Jinja2 (based on Django's templating)
    • mako
    • Cog
    • Cheetah

    The python wiki also has an article on this topic, with many more suggestions.

    0 讨论(0)
  • 2020-12-14 08:27

    There is... But you're highly suggested to use a templating engine, or some other means of separating the presentation from the business layer.

    There are some available that use python as the templating language, but it's nasty because python is sensitive to whitespace, so special syntax hacks have to be added.

    0 讨论(0)
  • 2020-12-14 08:29

    Yes, I recall there was a python ASP plugin from activestate that works this way.

    0 讨论(0)
  • 2020-12-14 08:32

    Use Cheetah or another templating engine.

    0 讨论(0)
  • 2020-12-14 08:33

    Several templating engines support this in one way or another: Mako, Jinja, and Genshi are all popular choices.

    Different engines support different features of Python and may be better suited to your needs. Your best bet is to try them out and see what works.

    0 讨论(0)
提交回复
热议问题