Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52193
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <skip.montanaro@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'historically': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'wrote': 0.14; 'arithmetic.': 0.16; 'did:': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'peters': 0.16; 'sender:addr:gmail.com': 0.17; 'module': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'skip': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'subject:time': 0.33; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'became': 0.64; 'to:addr:gmail.com': 0.65; 'world': 0.66; 'direct': 0.67 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=TTDdAFY8ffFEs5iuiBlu864/Mc6cyW6ArvyAgTXIUME=; b=RQgsGp5uDTgApUf1TOEZiF9sB8ynJEh8+LbJOHzRIIJUSUXx57GaBXIoxFmJpQt+Dp JxS2P7saLO73SzoHXOQ/9K9oC28A+ziuLCw4Iuba4TOjHKu/utK525u8m5EDXhGjzIKS mmkphJ80c8tc1Rs6noPlu8KfS4o4SWIUKdS9G4XsrNR6a9ycmhylTERejHGijQ+5D9Vx 4sIPuBPB+8Tj+PDT6SUd3LL+Wod6+nvezMDBFeSPWMOygZ8NQ3lzqv4JRaEGC+bxCfgj 49UqoJHc3z3CHE5s/rlVHIN4qjSLe57IMMo4mAP1/UKHpXtOF/skory52xhdoVTWFiKP egHA== |
| MIME-Version | 1.0 |
| X-Received | by 10.58.248.40 with SMTP id yj8mr2894793vec.40.1375963411823; Thu, 08 Aug 2013 05:03:31 -0700 (PDT) |
| Sender | skip.montanaro@gmail.com |
| In-Reply-To | <32a94a22-107c-4575-8808-d9355d635e83@googlegroups.com> |
| References | <b5df0633-c6fe-4489-adda-5b9f270a904d@googlegroups.com> <07f6b1c7-069d-458b-a9fe-ff30c09f2f2d@googlegroups.com> <roy-7D52A5.10334804082013@news.panix.com> <32a94a22-107c-4575-8808-d9355d635e83@googlegroups.com> |
| Date | Thu, 8 Aug 2013 07:03:31 -0500 |
| X-Google-Sender-Auth | -DHQLCs6oUraqpP4QeAFPFJrthM |
| Subject | Re: outputting time in microseconds or milliseconds |
| From | Skip Montanaro <skip@pobox.com> |
| To | matt.doolittle33@gmail.com |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.349.1375963829.1251.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375963829 news.xs4all.nl 15910 [2001:888:2000:d::a6]:58892 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:52193 |
Show key headers only | View raw
> 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",)))
Note that you don't need the time module here. Datetime objects have
what you need all by themselves:
from datetime import datetime
now = datetime.now()
self.logfile.write('%s\t%s\n' % (now.strftime("%Y-%m-%d"),
now.strftime("%H:%M:%S.%f")))
The time module was historically the way Python did time, but it
wasn't at all object-oriented and provided no direct support for date
arithmetic. When Tim Peters wrote datetime, the world became a better
place. Cozy up to the datetime documentation and put the time module
aside.
Skip
Skip
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
outputting time in microseconds or milliseconds matt.doolittle33@gmail.com - 2013-08-02 03:54 -0700
Re: outputting time in microseconds or milliseconds Dave Angel <davea@davea.name> - 2013-08-02 12:08 +0000
Re: outputting time in microseconds or milliseconds Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-08-02 13:59 +0200
Re: outputting time in microseconds or milliseconds matt.doolittle33@gmail.com - 2013-08-02 06:17 -0700
Re: outputting time in microseconds or milliseconds Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-08-05 08:15 +0200
Re: outputting time in microseconds or milliseconds Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-02 12:35 +0000
Re: outputting time in microseconds or milliseconds matt.doolittle33@gmail.com - 2013-08-02 08:09 -0700
Re: outputting time in microseconds or milliseconds Skip Montanaro <skip@pobox.com> - 2013-08-02 07:37 -0500
Re: outputting time in microseconds or milliseconds matt.doolittle33@gmail.com - 2013-08-02 07:18 -0700
Re: outputting time in microseconds or milliseconds Skip Montanaro <skip@pobox.com> - 2013-08-02 10:15 -0500
Re: outputting time in microseconds or milliseconds Chris Angelico <rosuav@gmail.com> - 2013-08-02 13:50 +0100
Re: outputting time in microseconds or milliseconds matt.doolittle33@gmail.com - 2013-08-04 04:30 -0700
Re: outputting time in microseconds or milliseconds Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-08-04 13:57 +0200
Re: outputting time in microseconds or milliseconds Dave Angel <davea@davea.name> - 2013-08-04 13:38 +0000
Re: outputting time in microseconds or milliseconds Roy Smith <roy@panix.com> - 2013-08-04 10:33 -0400
Re: outputting time in microseconds or milliseconds matt.doolittle33@gmail.com - 2013-08-07 19:51 -0700
Re: outputting time in microseconds or milliseconds Skip Montanaro <skip@pobox.com> - 2013-08-08 07:03 -0500
Re: outputting time in microseconds or milliseconds Roy Smith <roy@panix.com> - 2013-08-08 09:30 -0400
csiph-web