V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
durden
V2EX  ›  Python

能否如同PHP一样,将Python嵌入到HTML中去?

  •  
  •   durden · 2012-03-30 12:46:33 +08:00 · 11035 次点击
    这是一个创建于 4409 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我觉得对于很简单的web应用PHP的嵌入HTML的写法挺好的,让作者能将注意力放到功能/设计的实现上去,但较之PHP更中意Python的语法,请问能否如同PHP一样,将Python嵌入到HTML中去呢?
    6 条回复    1970-01-01 08:00:00 +08:00
    insraq
        1
    insraq  
       2012-03-30 12:50:21 +08:00
    再简单的应用,直接把Program嵌入到HTML都是一个很**糟糕**的做法。如果你像保持简介,考虑用Microframework,至于生成View,还是交给Template engine吧。
    yanng
        2
    yanng  
       2012-03-30 13:00:04 +08:00
    顶楼上,将html嵌入到逻辑代码中是个比较糟糕的想法,python的框架如django等都是努力将逻辑和表现分离开的。
    Vim
        3
    Vim  
       2012-03-30 13:03:26 +08:00
    可以的,你查一下 PSP(Python Server Page)

    不过同楼上诸位,不建议这样做
    durden
        4
    durden  
    OP
       2012-03-30 13:08:00 +08:00
    谢谢大家的建议,谢谢@vim 提供的链接
    glasslion
        5
    glasslion  
       2012-03-30 17:41:59 +08:00
    用吧,PSP现在应该没人在用了
    豆瓣,python.org,reddit.com用的都是Mako,也可以用在Pylons Pyramid tornato等框架中
    clino
        6
    clino  
       2012-04-01 09:09:21 +08:00
    uliweb 可以,是一个很棒的框架,在 html 里使用 python 很方便阿,没觉得有什么坏处,当然前提是不能乱用了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5826 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 06:10 · PVG 14:10 · LAX 23:10 · JFK 02:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.