Creating time stamps

MRAB python at mrabarnett.plus.com
Mon Jul 22 18:38:51 EDT 2019


On 2019-07-22 22:41, Grant Edwards wrote:
> On 2019-07-22, Michael F. Stemper <michael.stemper at gmail.com> wrote:
> 
>>>>   from datetime import datetime
>>>>   from time import strftime
>>>>   timestamp = datetime.now().strftime( "%Y-%m-%d %H:%M" )
> [...]
>> Apparently, the strftime() in that last line is not the one that I
>> explicitly imported, but a method of datetime.now(). Did I get that
>> right?
> 
> Exactly.
> 
You can tell that it's a method because it's:

something.strftime(...)

If it was using the imported 'strftime' then it would be:

timestamp = strftime(...)



More information about the Python-list mailing list