- Introducing system time class
import time
- Use class time time () method to get the timestamp (very exact value)
print(time.time()) #获得系统此刻的时间戳
- The current time and date printing system
print(time.time())
print(time.strftime("%H:%M:%S")) ##24小时格式
print(time.strftime("%I:%M:%S"))## 12小时格式
print(time.strftime("%Y/%m/%d %I:%M:%S"))## 带日期的12小时格式
Output:
时间戳:1531106213.6334727
24小时制:11:16:53 -->上午11点
12小时制:11:16:53
带日期的12小时制:2018/07/09 11:16:53
Therefore, the time code corresponding to the time:
- % A abbreviated weekday
- % A week's full name
- % B abbreviated month of
- % B Full name of month
- Time series Date% c Standard
- % C last two digits of the year
- % D day of the month in decimal notation
- % D month / day / year
- The first few days of each month in the two-character domain% e, decimal notation
- % F year - month - day
- % G last two digits of the year, based on weeks
- Year% G, based on weeks
- % H abbreviated month name
- % H 24-hour clock
- % I 12 hour clock
- % J day of the decimal representation of a year
- January% m decimal notation
- % M when ten minutes system represented by
- % N newline
- % P local AM or PM display equivalent
- % R 12 hours
- % R displays hours and minutes: hh: mm
- % S decimal seconds
- % T horizontal tab
- % T display minutes and seconds: hh: mm: ss
- % U day of week, Monday as the first day (the value from 0 to 6, 0 to Monday)
- % U week number of the year, the Sunday as the first day (value from 0-53)
- % V week number of year, based on weeks
- % W weeks several decimal notation (a value from 0 to 6, Sunday is 0)
- % W week number of year, Monday as the first day (value from 0-53)
- % X standard date string
- Standard time series% X
- Decimal% y year without century (values from 0 to 99)
- % Y lug ten years made part of the century
- % Z,% Z time zone name, the name of a time zone can not be obtained if the space character is returned.
- %% percent sign