Peter Moscatt <[EMAIL PROTECTED]> wrote:

> I am wanting to return the system date using the following:
> 
>       date.today()
> 
> How would I then convert this to a string ?
> 
> Pete

datetime.data objects have a __str__() method.  To convert one to a string, 
you just have to cause its __str__() to be invoked.  The most common ways 
of doing that are str(), %s, or print:

>>> import datetime
>>> d = datetime.date.today()
>>> d
datetime.date(2005, 5, 14)   # this is the repr() of the object
>>> print d
2005-05-14
>>> str(d)
'2005-05-14'
>>> '%s' % d
'2005-05-14'
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to