How do I output lists as a table in Jupyter notebook?

后端 未结 11 1026
灰色年华
灰色年华 2021-01-30 09:51

I know that I\'ve seen some example somewhere before but for the life of me I cannot find it when googling around.

I have some rows of data:

data = [[1,2         


        
11条回答
  •  无人及你
    2021-01-30 10:33

    You could try to use the following function

    def tableIt(data):
        for lin in data:
            print("+---"*len(lin)+"+")
            for inlin in lin:
                print("|",str(inlin),"", end="")
            print("|")
        print("+---"*len(lin)+"+")
    
    data = [[1,2,3,2,3],[1,2,3,2,3],[1,2,3,2,3],[1,2,3,2,3]]
    
    tableIt(data)
    

提交回复
热议问题