Python 1.5.2 -- assigning current time to a variable?
Jeremy Jones
Jeremy.Jones at peregrine.com
Wed Oct 31 12:30:28 EST 2001
>Using:
>timestring = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
>Yields:
>TypeError: function requires at least one argument
I'm sure that someone else could point out a more obvious, simpler solution,
but this works:
>>> from time import *
>>> strftime("%Y-%m-%d %H:%M:%S", localtime(int(time())))
'2001-10-31 12:43:34'
strftime expects a format and a tuple. localtime(int(time())) generates a
tuple.
More information about the Python-list
mailing list