Purpose: Learn the time module in Python to get the current or time period
Environment: Ubuntu 16.04 python3.5.2
The time module is a built-in module that can be used to get current times, dates, and to set a delay or countdown.
Import the module before you use it
Import time
Common methods are: Sleep (), strftime (), CTime ()
Sleep (t), sets the number of T, in seconds, and can have decimal points, which is understood as the number of seconds to delay execution.
Time.sleep (5)
Wait 5 seconds to continue executing the following statement.
Strftime ("), format output the current time, the parameters in quotation marks, the date of the month and seconds, multiple selection, regardless of order.
Strftime ('%y%m%d_%h%m%s ')
Returns for example 2017060713_231415 this format, each of which represents an argument between the parameters can be added as underlined.
%Y returns a 4-digit year
%y returns a 2-digit year
%m returns a 2-digit month
%H return English month abbreviation
%d returns a 2-digit day
%d Returns two bits per month/day/year format
%x with%d
When%x returns: minute: Two bits in seconds format
%H returns 24-hour system hours
%l returns 12-hour system hours
%p return AM or PM
%M return 2-digit-minute number
%s returns 2-digit number of seconds
%z return time zone such as +0800
%Z return time zone such as CST
CTime (), return the full time such as: ' Thu Jul 13 23:31:39 2017 '
This article is from the "Rickyhul" blog, make sure to keep this source http://rickyh.blog.51cto.com/10934856/1947353
Using the time-period module in Python