Python time module ⌚

Veröffentlicht am: 25 Januar 2021
auf dem Kanal: Bro Code
54,744
1.6k

python time module tutorial example explained

#python #time #module

***************************************************************************
import time
***************************************************************************
print(time.ctime(0)) # convert a time expressed in seconds since epoch to a readable string
epoch = when your computer thinks time began (reference point)
print(time.time()) # return current seconds since epoch
print(time.ctime(time.time())) # will get current time

***************************************************************************
time.strftime(format, time_object) = formats a time_object to a string
time_object = time.localtime() # local time
time_object = time.gmtime() # UTC time
local_time = time.strftime("%B %d %Y %H:%M:%S", time_object)
print(local_time)

***************************************************************************
time.strptime(string_string, format) = parses a string representing time/date and returns a struct_time object
time_string = "20 April, 2020"
time_object = time.strptime(time_string,"%d %B, %Y")
print(time_object)

***************************************************************************
time.asctime(time_tuple) = accepts a time_object or a tuple up to 9 elements and returns a string
(year, month, day, hours, minutes, secs, #day of the week, #day of the year, dst)
time_tuple = (2020, 4, 20, 4, 20, 0, 0, 0, 0)
time_string = time.asctime(time_tuple)
print(time_string)

***************************************************************************
time.asctime(time_tuple) = accepts a time_object or a tuple up to 9 elements and return seconds since epoch
(year, month, day, hours, minutes, secs, #day of the week, #day of the year, dst)
time_tuple = (2020, 4, 20, 4, 20, 0, 0, 0, 0)
time_string = time.mktime(time_tuple)
print(time_string)

***************************************************************************

music credits 🎼 :
===========================================================
Up In My Jam (All Of A Sudden) by - Kubbi   / kubbi  
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
Free Download / Stream: http://bit.ly/2JnDfCE
Music promoted by Audio Library    • Up In My Jam (All Of A Sudden) – Kubbi (No...  
===========================================================


Auf dieser Seite können Sie das Online-Video Python time module ⌚ mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Bro Code 25 Januar 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 54,744 Mal angesehen und es wurde von 1.6 tausend den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!