To get time-related information, you'll want to use the Python timer module, which has a lot of very handy features that you can go to the official
The document understands the current time to take, to get the timestamp of the current time, the time stamp seems to be between 1970 and now time interval.
You can try the following way to get the time stamp of the current time:
Import time
Print Time.time ()
The result of the output is:
1279578704.6725271
But this is a series of numbers that are not the result we want, and we can use the time module's format to handle:
Time.localtime (Time.time ())
Using the Time.localtime () method, the effect is to format the time that the timestamp is local.
The result of the output is:
Time.struct_time (tm_year=2010, tm_mon=7, tm_mday=19, tm_hour=22, tm_min=33, tm_sec=39, tm_wday=0, tm_yday=200, tm_ isdst=0)
Now it looks like it's a more hopeful format for the time we want.
Time.strftime ('%y-%m-%d ', Time.localtime (Time.time ()))
Finally, using the Time.strftime () method to format just a bunch of information into what we want, now the result is:
2010-07-19
Time.strftime has a lot of parameters that allow you to more freely output what you want:
The following are the parameters of the Time.strftime:
Strftime (format[, tuple])-> string
Converts the specified struct_time (the default current time) to the specified formatted string output
Time date format symbol in Python:
%y Two-digit year representation (00-99)
%Y Four-digit year representation (000-9999)
%m Month (01-12)
Day of%d months (0-31)
%H 24-hour hours (0-23)
%I 12 Hours of hours (01-12)
%m minutes (00=59)
%s seconds (00-59)
%a Local Simplified Week name
%A Local Full week name
%b a locally simplified month name
%B Local Full month name
%c Local corresponding date representation and time representation
%j Day of the Year (001-366)
%p the equivalent of a local a.m. or p.m.
%u number of weeks in a year (00-53) Sunday is the beginning of the week
%w Week (0-6), Sunday for the beginning of the week
%w number of weeks in a year (00-53) Monday is the beginning of the week
%x Local corresponding date representation
%x Local corresponding time representation
%Z the name of the current time zone
%%% per se