10
如何獲得一個整數在python 3.2中使用format屬性將0填充爲固定寬度? 實施例:固定寬度數字格式化python 3
a = 1
print('{0:3}'.format(a)}
給出 '1',而不是 '001' 我想。在蟒蛇2.x中,我知道,這可以使用
print "%03d" % number.
我檢查了Python 3的字符串的文件,但沒有能夠得到這個工作要做。
http://docs.python.org/release/3.2/library/string.html#format-specification-mini-language
感謝。