在PrettyTable Python中插入不同的长度列表

时间:2018-02-06 19:53:13

标签: python prettytable

titles =('IP','URL')
t = PrettyTable([])
list1 = ['8.8.8.8', '8.8.8.8', '8.8.8.8', '8.8.8.8', ]
list2 = ['http://www.example.com', 'http://www.example.com', ]
for title,lst in zip(titles,itertools.izip_longest(list1,list2,fillvalue="")):
    t.add_column(title,lst)

print t

显示代码输出:

What the code provides

显示我真正想要的内容:

What I want

0 个答案:

没有答案