这是代码:
print "Unsorted \t Bubble \t Insertion"
for x, y, z in zip(List, arr_bs, arr_is):
print '{0:2d}\t\t{1:3d}\t\t{2:4d}'.format(x, y, z)
print "Seconds: \t %f \t %f" % (time_bs, time_is)
Run Code Online (Sandbox Code Playgroud)
这是输出:
Unsorted Bubble Insertion
43 5 5
88 18 18
57 24 24
86 37 37
81 37 37
18 38 38
5 43 43
24 57 57
76 76 76
37 81 81
37 86 86
38 88 88
Seconds: 0.000091 0.000042
Run Code Online (Sandbox Code Playgroud)
啊,无法让输出看起来像在终端中那样,但你明白了.我是python的新手,有更多pythonic方式来格式化这些打印语句吗?
欢迎提出意见,谢谢.