http://docs.python.org/library/stdtypes.html#str.zfill
Python: Nicest way to pad zeroes to string - Stack Overflow
http://stackoverflow.com/questions/339007/python-nicest-way-to-pad-zeroes-to-string
python int 補零
$python
Python 2.7.2 (default, Oct 12 2011, 01:40:25)
[GCC 4.2.2 20070831 prerelease [FreeBSD]] on freebsd9
Type "help", "copyright", "credits" or "license" for more information.
>>> num='2'
>>> num.zfill(2)
'02'
>>> num.zfill(3)
'002'
>>> num.zfill(4)
'0002'
沒有留言:
張貼留言