0

I am programming my first website with flask one of my sections is a list of all sub-users for the teacher's class so how can I use prettytable with flask to get a table my end goal is a table that looks like this (just the data)

        Teacher | Student          |    Id    | GPA | Last sign learned 
        ----------------------------------------------------------------
        Medina  | John doe         | 19500688 | 4.0 | Bad
        Medina  | Samantha babcock | 91234094 | 2.5 | Toilet
        Jonson  | Steven smith     | 64721881 | 3.0 | Santa

How can I do this preferably with Pretty table but any method would be great!

4

1 回答 1

1

你好,所以你的表单很容易创建,但是让我们从 python 的静态信息开始

 def function():            
            from prettytable import *
            table = PrettyTable(["Teacher","Student"," ID","GPA"," Last sign learned "])
            table.add_row(["Medina","John doe","19500688","4.0","Bad"])
            table.add_row(["Medina","Samantha babcock ","91234094","2.5","Toilet"])
            table.add_row(["Jonson","Steven smith","64721881","3.0","Santa"])
            return render_template("info.html", tbl=table.get_html_string(attributes = {"class": "foo"}))

现在为您提供 HTML:

{%extends "template.html"%}
    {{tbl|safe}}
于 2013-12-15T18:27:03.440 回答