Wednesday, July 16, 2014

How to get the current time in Python

Code
from time import strftime                                              #1
print strftime("%H:%M:%S")                                             #2


How this works - Line by Line

from time import strftime                                              #1
 
Imports the strftime function from the time module, which is standard


print strftime("%H:%M:%S")                                             #2

Prints the current local time.

No comments:

Post a Comment