推荐学习书目
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 · Jul 3, 2017 · 2434 views
    This topic created in 3323 days ago, the information mentioned may be changed or developed.

    查了半天,还是不会。。

    5 replies    2017-07-04 20:29:14 +08:00
    bearqq
        1
    bearqq  
       Jul 3, 2017 via Android
    搜 django html 表格,忘掉 prettytable
    ToughGuy
        2
    ToughGuy  
       Jul 3, 2017
    content = PrettyTable.whatever()
    return HttpResponse('<pre>{}</pre>'.format(content))

    不过需求很奇葩哈, 既然是 html 为啥不直接用 table
    1002149271
        3
    1002149271  
    OP
       Jul 4, 2017
    @ToughGuy PrettyTable.whatever() 这个是什么意思
    1002149271
        4
    1002149271  
    OP
       Jul 4, 2017
    @ToughGuy 我怎么通过 django 在网页调用我这个 python 脚本的输出,我看好像只有通过 view 写响应函数,难道把所有程序移到 view 里面?
    1002149271
        5
    1002149271  
    OP
       Jul 4, 2017
    @ToughGuy PrettyTable.whatever() 这个是怎么用的,前面那个 PrettyTable 是定义的变量吗?为什么我用了这个网页显示 whtever 这个值是错的
    Exception Type: AttributeError
    Exception Value: whatever
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2826 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 14:22 · PVG 22:22 · LAX 07:22 · JFK 10:22
    ♥ Do have faith in what you're doing.