Print list in table format in python

后端 未结 5 1516
春和景丽
春和景丽 2020-12-31 18:27

I am trying to print several lists (equal length) as columns of an table.

I am reading data from a .txt file, and at the end of the code, I have 5 lists, which I wou

5条回答
  •  清歌不尽
    2020-12-31 19:08

    I'll show you a 3-list analog:

    >>> l1 = ['a', 'b', 'c']
    >>> l2 = ['1', '2', '3']
    >>> l3 = ['x', 'y', 'z']
    >>> for row in zip(l1, l2, l3):
    ...     print ' '.join(row)
    
    a 1 x
    b 2 y
    c 3 z
    

提交回复
热议问题