这是我用python编写的脚本的一部分:
print 'Url\t\tpopularity_rank\t\treach_rank\t\tcountry_rank'
urls = open(filename)
for site in urls:
url = site.rstrip()
data = Func(url)
popularity_rank, reach_rank, country_rank = -1, -1, -1
if data:
popularity_rank, reach_rank , country_rank = data
print '%s\t%d\t%d\t%d' % (url, popularity_rank, reach_rank, country_rank)
输出如下:
^{pr2}$如何使用ljust()
在一个漂亮的列中获得输出?在
这个怎么样-没有
ljust()
也没有\t
一。在
^{pr2}$编辑:
如果您不知道需要在格式化字符串中使用
*
多长的列。但是在找到
longest
之前,您需要知道所有的值。在一。在
相关问题 更多 >
编程相关推荐