The-time of the Python module

Source: Internet
Author: User

Python module time

Import Time # 1 times (): Returns the timestamp of the current time Time.time () #1473525444.037215 #--------------------------------------------------- -------# 2 localtime ([secs]) # Converts a timestamp to the struct_time of the current time zone. The secs parameter is not provided, whichever is the current time. Time.localtime () #time. Struct_time (tm_year=2016, tm_mon=9, tm_mday=11, tm_hour=0,# tm_min=38, tm_sec=39, Tm_wday=6, TM _yday=255, tm_isdst=0) Time.localtime (1473525444.037215) #------------------------------------------------------- ---# 3 gmtime ([secs]) is similar to the LocalTime () method, the Gmtime () method is the struct_time of converting a timestamp to the UTC time zone (0 o'clock Zone). #----------------------------------------------------------# 4 Mktime (t): Converts a struct_time to a timestamp. Print (Time.mktime (time.localtime)) #1473525749.0 #----------------------------------------------------------# 5 Asctime ([t]): A tuple or struct_time representing time is expressed in this form: ' Sun June 20 23:21:05 1993 '. # If there are no arguments, time.localtime () will be passed in as a parameter. Print (Time.asctime ()) #Sun Sep 00:43:43 #----------------------------------------------------------# 6 CTime ([ secs]): Converts a timestamp (floating point number in seconds) into the form of time.asctime (). If the parameter is not given or is# when none, the default Time.time () will be the parameter. Its function is equivalent to Time.asctime (time.localtime (secs)). Print (Time.ctime ()) # Sun Sep 00:46:38 Print (Time.ctime (Time.time ()) # Sun Sep one 00:46:38 # 7 strftime (fo rmat[, T]): Converts a tuple or struct_time that represents time (such as returned by Time.localtime () and # Time.gmtime ()) to a formatted time string. If T is not specified, the Time.localtime () is passed in. If any of the # elements in the tuple are out of bounds, the ValueError error will be thrown. Print (Time.strftime ("%y-%m-%d%x", Time.localtime ())) #2016 -09-11 00:49:56 # 8 Time.strptime (string[, format]) # Converts a formatted time string to Struct_time. In fact it is inverse operation with strftime (). Print (Time.strptime (' 2011-05-05 16:37:06 ', '%y-%m-%d%x ')) #time. Struct_time (tm_year=2011, tm_mon=5, tm_mday=5, tm_  Hour=16, tm_min=37, tm_sec=6,# tm_wday=3, tm_yday=125, tm_isdst=-1) #在这个函数中, format defaults to: "%a%b%d%h:%m:%s%Y". # 9 Sleep (secs) # thread postpones the specified time run, in seconds. # ten clock () # This needs to be noted on different systems with different meanings. On a UNIX system, it returns "process time", which is a floating-point number (timestamp) in seconds. # and in Windows, the first call, returns the actual time that the process is running. The second subsequent call is the run # time from the first call to the present, which is the two time difference.

  

The-time of the Python module

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.