formatting numbers

Robert Gahan gahanr at
Mon Jun 4 16:33:22 EDT 2001

michael montagne <montagne at> wrote in message
news:e5SS6.69668$FS3.619704 at
> Simple question.  I am accessing a database of job numbers that take the
> form of "00049" and "01049".  These values are integers.  When I return
> value from the database it reads "49".  I need to add the leading digits
> they are there so this number would read "00049".  In MSAccess I used
> Format(num,"00000").  How can I do that with Python?
> -mjm

This (or something similar) might do the trick ...

jobNo = 49

key = "%.5d" % (jobNo)
print key

More information about the Python-list mailing list