Print list in table format in python

后端 未结 5 1517
春和景丽
春和景丽 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 18:46

    for nested_list in big_container_list
        print '\t'.join(nested_list)
    

    with \t being the tabulation character

    quick example:

    In [1]: a = [['1','2'],['3','4']]
    In [5]: for nested_list in a:
    ...:     print '\t'.join(nested_list)
    ...: 
    1       2
    3       4
    

提交回复
热议问题