outputting time in microseconds or milliseconds

matt.doolittle33 at gmail.com matt.doolittle33 at gmail.com
Wed Aug 7 22:51:47 EDT 2013


> 
> Taking a step back, you're probably better off using datetimes.  You'll 
> 
> get all this conversion nonsense for free:
> 
i did: 

   from time import strftime, time
   from datetime import datetime

   now = datetime.now()

   self.logfile.write('%s\t'%(strftime("%Y-%m-%d",)))
   self.logfile.write('%s\t'%(now.strftime("%H:%M:%S.%f",)))

this gives me:

2013-08-04	14:01:27.906126
2013-08-04	14:01:28.052273
2013-08-04	14:01:28.058967
2013-08-04	14:01:28.243959
2013-08-04	14:01:28.251107
2013-08-04	14:01:28.251268
2013-08-04	14:01:28.251373
2013-08-04	14:01:28.251475
2013-08-04	14:01:28.424568
2013-08-04	14:01:28.612548
2013-08-04	14:01:28.616569
2013-08-04	14:01:28.616727
2013-08-04	14:01:28.792487
2013-08-04	14:01:28.796226

thats what i need. Thanks!



More information about the Python-list mailing list