2011-07-29 34 views

回答

29

前綴與0寬度:

>>> '{0:03}'.format(1) 
'001' 

而且,你並不需要的地方,標誌物Python的最近版本(不知道哪個,但至少2.7和3.1):

>>> '{:03}'.format(1) 
'001'