>>> 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
谢谢。
最佳答案
print 'there are {0:<10} students and {1:<10} teachers'.format(scnt, tcnt)
虽然老%
运算符(operator)使用 -
为了对齐,新的 format
方法使用 <
和 >
关于python - str.format() -> 如何左对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/829667/