# ! /Usr/bin/Python
# Coding = UTF-8
From Datetime Import Datetime, date, time
"""
The date type, as its name implies, only represents the date, and time only represents the time
"""
Today = date. Today ()
Attrs = [
( " Year " , " Year " ),( ' Month ' , " Month " ),( ' Day ' , " Day " )
]
For K, V In Attrs:
" Today. % s = % s # % s " % (K, getattr (today, k), V)
# The day of the week. Same as datetime rules
Today. isoweekday ()
Today. weekday ()
# Returns a time structure. Of course, there is no time information.
Today. timetuple ()
# Modify. Same as datetime rules
Today. Replace (month = 1)
# It cannot be converted back to a string.
Today. strftime ( " % Y-% m-% d " )
Now = Time (12, 13, 14)
Attrs = [
( " Hour " ," Hours " ),( ' Minute ' , " Minute " ),( ' Second ' , " Seconds " ),( " Microsecond " , " Millisecond " )
]
For K, V In Attrs:
" Now. % s = % s # % s " % (K, getattr (now, k), V)
# Modify. Same as datetime rules
Now. Replace (minute = 1)
# It cannot be converted back to a string.
Now. strftime ( " % H: % m: % s " )
# Merge date and time into datetime
Print Datetime. Combine (today, now)