On May 2, 10:21 am, HMS Surprise <[EMAIL PROTECTED]> wrote: > On May 2, 12:03 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > In <[EMAIL PROTECTED]>, HMS Surprise > > wrote: > > > > I wish to generate a datetime string that has the following format. > > > '05/02/2007 12:46'. The leading zeros are required. > > > > I found '14.2 time' in the library reference and have pulled in > > > localtime. Are there any formatting functions available or do I need > > > to make my own? Perhaps there is something similar to C's printf > > > formatting. > > > You mean like `time.strftime()`!? :-) > > > Ciao, > > Marc 'BlackJack' Rintsch > > Thanks for posting. > > I think I have an import misconception. > > I use > import from time localtime, strftime > t = strftime('%m/%d/%Y %H:%M', localtime()) > > This works. How would one use it with the module name pre-pended? > > thanx, > jvh
I would think that what you have written there shouldn't work at all... it would need to be: [code] from time import localtime, strftime [/code] to use the prepended module name just do this instead: [code] import time t = time.strftime('%m/%d/%Y %H:%M', time.localtime()) [/code] -- http://mail.python.org/mailman/listinfo/python-list