Thursday, 2 February 2017

python - Access Real Time on Computer

import time

print time.strftime('%I:%M:%S %p %Z')



For me, prints 12:21:51 PM EDT



Edit: Just want to clarify the place holders.



%I = Hour (12-hour clock) as a decimal number [01,12].
%M = Minute as a decimal number [00,59].
%S = Second as a decimal number [00,61].
%p = Locale’s equivalent of either AM or PM.
%Z = Time zone name (no characters if no time zone exists).

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...