On 03May2017 00:01, Alan Gauld <alan.ga...@yahoo.co.uk> wrote:
On 02/05/17 19:09, Michael C wrote:
1. How to name the file with time stamp.   e.g.   05012017.png and so forth.

And so forth? I assume you mean

MMDDYYYY.png format?

You should read about the strftime function in the time
(and datetime) module. Other functions thee will find
the current date/time for you. Thee are examples on the
documentation pages but if you get stuck come back
with specific questioons.

Further to this, I would also advocate that you consider writing the timestamp from largest unit to smallest unit, like an ISO8601 timestamp, which typically looks like:

 YYYYMMDD.png

See:
 https://www.iso.org/iso-8601-date-and-time-format.html
 https://en.wikipedia.org/wiki/ISO_8601

This has the advantage that a lexical sort (as in a typical directory listing or file glob) automatically arranges names in date order.

I'd also remark that the USA centric format (MMDDYYYY) that Alan inferred is particularly unfortunate in that (a) the rest of the world generally use DDMMYYYY so that the units come in increasing size and (b) doesn't sort very nicely at all. Of course, you might have meant 5th December 2017 above, so who knows? But the very ambiguity makes this one to avoid.

For numeric timestamps like yours I only ever use YYYYMMDD (or the obvious variants like YYYY-MM-DD etc). If I use another, I make the month a word (lousy for sorting and parsing, but clear to the human reader); I only do that in prose, not in filenames.

Cheers,
Cameron Simpson <c...@zip.com.au>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to