格式化输出:str.format()的用法
for x in range(1,11): print('{0:2d} {1:3d} {2:4d}'.format(x, x*x,x*x*x))
----------输出如下----------
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000
table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678} for name ,num in table.items(): print('{0:10}------>{1:10d}'.format(name ,num))
----------输出如下----------
Dcab ------> 7678
Jack ------> 4098
Sjoerd ------> 4127