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
1002149271
V2EX  ›  Python

PrettyTable 这个怎么输出到 django 的网页上?

  •  
  •   1002149271 · 2017-07-03 16:56:24 +08:00 · 1903 次点击
    这是一个创建于 2482 天前的主题,其中的信息可能已经有所发展或是发生改变。

    查了半天,还是不会。。

    5 条回复    2017-07-04 20:29:14 +08:00
    bearqq
        1
    bearqq  
       2017-07-03 17:23:31 +08:00 via Android
    搜 django html 表格,忘掉 prettytable
    ToughGuy
        2
    ToughGuy  
       2017-07-03 19:32:19 +08:00
    content = PrettyTable.whatever()
    return HttpResponse('<pre>{}</pre>'.format(content))

    不过需求很奇葩哈, 既然是 html 为啥不直接用 table
    1002149271
        3
    1002149271  
    OP
       2017-07-04 17:51:32 +08:00
    @ToughGuy PrettyTable.whatever() 这个是什么意思
    1002149271
        4
    1002149271  
    OP
       2017-07-04 18:06:55 +08:00
    @ToughGuy 我怎么通过 django 在网页调用我这个 python 脚本的输出,我看好像只有通过 view 写响应函数,难道把所有程序移到 view 里面?
    1002149271
        5
    1002149271  
    OP
       2017-07-04 20:29:14 +08:00
    @ToughGuy PrettyTable.whatever() 这个是怎么用的,前面那个 PrettyTable 是定义的变量吗?为什么我用了这个网页显示 whtever 这个值是错的
    Exception Type: AttributeError
    Exception Value: whatever
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1910 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 16:16 · PVG 00:16 · LAX 09:16 · JFK 12:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.