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
显示代码输出:
显示我真正想要的内容: