Time module:UTC (World Standard Time): Greenwich Astronomical Time. China time and UTC relationship: China time =utc+8DST (Daylight saving time): It is a kind of energy saving and it is considered as specified, and it is 1 hours faster in
Current timestamp: Time.time ()Current date: Time.ctime ()
Get current time:
Ymdhms = Time.strftime ('%y-%m-%d%h:%m:%s ', Time.localtime (Time.time ()))Timearray = Time.strptime (ymdhms, "%y-%m-%d%h:%m:%s")
Current Time Date stamp
A datetime module is a collection of date and time two modules. There are 2 constants in the DateTime module: Maxyear has a value of 9999,minyear of 1.The DateTime module defines 5 classes, each of which isDatetime.date: A class that represents a
To get time-related information, use the Python times module, which has a lot of features that are very useful to you, and you can go to the officialThe document understands that the current time to fetch is the time stamp of the current time, and
def get_time(): time_array = time.localtime() time_array = time.mktime(time_array) return time.strftime("%Y %m %d %H:%M:%S", time.gmtime(time_array))Python format symbols in time Date:%y Two-digit year representation (00-99)%Y Four-digit year
There are two modules for Python processing time, which are times, datetime, calendar1> timePrint(Time.gmtime ())Print(Time.localtime ())#the current time is returned by a Time.struct_time objectPrint(Time.time ())#The time stamp of the current time
A Module introduction1. What is a module?#常见的场景: A module is a python file that contains a set of functions, such as spam.py, which is named spam and can be used via import spam. #在python中, the module is used the same way, but in fact, the module
Most of the content was excerpted from the blog http://www.cnblogs.com/Eva-J/Collections ModuleOn the basis of the built-in data type (DICT, list, set, tuple),The collections module also provides several additional data types: Counter, deque,
Basic Custom Type
Copy Code code as follows:
C.__init__ (self[, arg1, ...]) builder (with some optional parameters)
C.__new__ (self[, arg1, ...]) constructor (with some optional parameters); typically used in a subclass that sets
Import time
print (' {} '. Format (time.strftime ('%y-%m-%d%h:%m:%s ', Time.localtime (Time.time ())))
Time.strftime has a lot of parameters that allow you to more freely output what you want:
The following are the parameters of the
Reproduced from: http://web.jobbole.com/89120/
The Knowledge Atlas of this section refers to the Atlas of programming language knowledge-time and date.
This article JavaScript time and date processing combat: You must be trapped from the author's
1. Two ways to get the current time:Import Datetime,timenow = Time.strftime ("%y-%m-%d%h:%m:%s")Print nownow = Datetime.datetime.now ()Print now2. Get the last day of the month minus 1 days on the first day of the monthLast = Datetime.date (Datetime.
Python time module has a lot of very useful features in Python when it gets information about the timing.time.time()time stamp in Python to get the current time:>>> import time>>> print time.time()1438608599.0The time for printing here is from 1970
The basic time service provided by the Unix kernel is the number of seconds that have elapsed since 00:00:00, January 1, January 1, 1970 AD, The International Standard Time. This number of seconds is represented by the Data Type time_t.
1. The time
UNIX timestamp: the number of seconds that have elapsed since midnight on January 1, January 1, 1970 (UTC/GMT), regardless of the leap second.
Take 25/JUL/2012: 13: 26: 58 as an example.
Python program:
Import time
Import datetime
X = datetime.
Python time Strftime () methodDescribeThe Python time strftime () function receives an array of times and returns the local time as a readable string, in the format determined by the parameter format. GrammarStrftime () method syntax: Time .
This article briefly summarizes the Python processing time and date aspects of the module, mainly the use of datetime, three modules, I hope this article is useful for learning Python friends.
The first is the call of the module, many Ides have
1. Two ways to get the current time:
The code is as follows:
Import Datetime,timenow = Time.strftime ("%y-%m-%d%h:%m:%s")Print nownow = Datetime.datetime.now ()Print now
2. Get the last day of the month minus 1 days on the first day of the month
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.