strftime() in Python DateTime.
The strftime() method returns a string representing
date and time using date, time or datetime object.
The strftime() method takes one or more format codes
as an argument and returns a formatted string based on it.
Some commonly used format codes:
%m: Month as a zero-padded decimal number. Ex - 01,02,...12
%d: Day of the month as a zero-padded decimal. Ex - 01,02,...31
%Y: Year Ex - 2010,2019,...
%H: Hour (24-hour clock) as a decimal number. Ex - 0, 1,..,23
%M: Minute as a zero-padded decimal number. Ex - 00,01,..,59
%S: Second as a zero-padded decimal number. Ex - 00,01,..,59
"""
import datetime
curr_dt = datetime.datetime.now()
print(curr_dt)
print(curr_dt.strftime("%m"))
print(curr_dt.strftime("Date is %d-%m-%Y, Time is %H:%M:%S"))
Auf dieser Seite können Sie das Online-Video Code 46: strftime() in Python DateTime | Datetime Module | 365 Days of Code mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Code House 15 Februar 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 290 Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!