【发布时间】:2016-04-13 12:58:22
【问题描述】:
我在打印输出时遇到了一些问题...
我的代码:
def main():
total = 0
capital = ["Bern", "London", "Washington D.C"]
country = ["Switzerland", "England", "America"]
population = [0.126,8.539,0.659]
print " Capital\tCountry\t\tPopulation"
print "-------------\t-------------\t-------------"
for i in range(len(capital)):
print "%s\t%s\t%s"% (capital[i-1], country[i-1], population[i-1])
main()
输出:
Capital Country Population
------------- ------------- -------------
Washington D.C America 0.659
Bern Switzerland 0.126
London England 8.539
我正在尝试使输出看起来像这样:
Capital Country Population
------------- ------------- -------------
Washington D.C America 0.659
Bern Switzerland 0.126
London England 8.539
我已经尝试了很多通过添加和减少'\t'来调整输出但无法调整它...
任何帮助将不胜感激。 谢谢
【问题讨论】:
标签: python python-2.7