formatting numbers
Chris Barker
chrishbarker at home.net
Mon Jun 4 17:12:53 EDT 2001
> michael montagne <montagne at boora.com> wrote in message
> news:e5SS6.69668$FS3.619704 at sjc-read.news.verio.net...
> > value from the database it reads "49". I need to add the leading digits
> if
> > they are there so this number would read "00049". In MSAccess I used
> > Format(num,"00000"). How can I do that with Python?
try string.zfill
>>> import string
>>> string.zfill(49,5)
'00049'
>>>
Question: is there a way to do this with string methods?
--
Christopher Barker,
Ph.D.
ChrisHBarker at home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------
More information about the Python-list
mailing list