1. time module
Python programs can handle dates and times in many ways, and converting date formats is a common feature.
1 ) Time is classified in Generic Operating System Services, and the functions it provides are closer to the operating system level. The time module is built around Unix Timestamp
2 ) Timestamp refers to the total number of seconds from January 01 , 1970 00:00:00 ( GMT January 01 , 1970 08:00:00 ) to the present , and the result is a floating points
3 ) The date range that can be expressed is limited to 1970-2038
import time #time module used
print(time.time())
print(type(time.time()))
#Can complete basic time processing, print the current date or time
4) What is a time tuple?
Many Python functions process time with 9 groups of numbers assembled with a meta:
Second, the datetime module
1 ) date object, commonly used attributes are year, month, day
2 ) Time object, commonly used attributes are: hour, minute, second, microsecond
3 ) datetime date time object, commonly used attributes are year, month, day, hour, minute, second, microsecond
4 ) timed elta time interval, that is, the length between two time points
5 ) tzinfo timezone info object
import datetime #The datetime module used
print(datetime.datetime.now())
Results of the:
C: \ python \ python.exe C: /python/demo/file3.py
1519800723.2606907
<class 'float'>
2018-02-28 14:52:03.260690
Process finished with exit code 0