[Tutor] datetime.timedelta Output Format

William Allison allison.william at comcast.net
Mon Apr 2 01:48:04 CEST 2007


Is there a way to have the output of "print tis" in the same format as 
"print now" and "print tafmsd" in the code below?
Thanks,
Will


savage:~ wallison$ python
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import datetime
 >>> now = datetime.date.today()
 >>> print now
2007-04-01
 >>> tafmsd = datetime.date(1994, 2, 23)
 >>> print tafmsd
1994-02-23
 >>> tis = now - tafmsd
 >>> print tis
4785 days, 0:00:00
 >>>



More information about the Tutor mailing list