>>> print 'there are {0:10} students and {1:10} teachers'.format(scnt, tcnt)
there are 100 students and 20 teachers
代码是什么,以便输出成为:
there are 100 students and 20 teachers
感谢。
答案 0 :(得分:17)
print 'there are {0:<10} students and {1:<10} teachers'.format(scnt, tcnt)
虽然旧%
运算符使用-
进行对齐,但新format
方法使用<
和>