2009-05-06 4 views
8
>>> print 'there are {0:10} students and {1:10} teachers'.format(scnt, tcnt) 
there are  100 students and   20 teachers 

Was der Code sein würde, so dass der Ausgang wurde:str.format() -> wie man linksbündig

there are 100  students and 20   teachers 

Dank.

Antwort

17
print 'there are {0:<10} students and {1:<10} teachers'.format(scnt, tcnt) 

Während der alte % Operator - für die Ausrichtung verwendet, die neue format Methode verwendet < und >

Verwandte Themen