[Tutor] stfftime question

Tom Tucker tktucker at gmail.com
Tue Jul 4 09:56:53 CEST 2006


Below is an example of me converting a datetime to milliseconds on a
Mac running Pythong 2.3.5.  The same working code on a Solaris system
with Python 2.3.2 fails.  Any thoughts? What arguments am I missing?



>From my Mac
#############
Python 2.3.5 (#1, Oct  5 2005, 11:07:27)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> dtstr = datetime.datetime(1973,9,4,04,3,25,453)
>>> output = dtstr.strftime('%s.%%03d') % (dtstr.microsecond)
>>> print output
115977805.453


>From Work (Solaris)
################
Python 2.3.2 (#1, Nov 17 2003, 22:32:28)
[GCC 2.95.3 20010315 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> dtstr = datetime.datetime(1973,9,4,04,3,25,453)
>>> output = dtstr.strftime('%s.%%03d') % (dtstr.microsecond)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: not enough arguments for format string
>>>


More information about the Tutor mailing list