The time module of the Python module

Source: Internet
Author: User
Tags local time

Time Module

and time-related functional modules.

1, time stamp time

# Timestamp time  float display 1970 to current number of seconds print(Time.time ())  # 1515584512.4203668

2, Format time

# Format time format displays the current time for easy viewing Print (Time.strftime ('%y/%m/%d%h:%m:%s'))  # 2018/01/10 19:48:48 """     %+ Specifies the character:        Y represents the year that displays the full year number        Y is also  the two-bit m that represents the year after the year number is displayed for the        month display month        D represents the date display what        time H represents the hour shows several points 24-hour        M stands for minutes showing        a few seconds for seconds " " "

3, Structured time

#Structured Time#Show local timePrint(Time.localtime ())"""results: Time.struct_time (tm_year=2018, Tm_mon=1, tm_mday=11, tm_hour=15, tm_min=0, Tm_se C=31, Tm_wday=3, tm_yday=11, tm_isdst=0)"""#Show GMTPrint(Time.gmtime ())"""results: Time.struct_time (tm_year=2018, Tm_mon=1, tm_mday=11, tm_hour=7, tm_min=0, Tm_se C=31, Tm_wday=3, tm_yday=11, tm_isdst=0)"""

  The conversion between different format times.

#Timestamp- %a%b%d%h:%m:%s%y string#If no arguments are passed, the current time is returnedPrint(Time.ctime ())#Thu Jan 15:13:56 2018#structured Time--%a%b%d%h:%m:%s%y string#If no arguments are passed, the current time is returnedPrint(Time.asctime ())#Thu Jan 15:17:43 2018#format time--structured time#The format of the time and time of the conversionPrint(Time.strptime ('2018/1/11','%y/%m/%d'))"""results: Time.struct_time (tm_year=2018, Tm_mon=1, tm_mday=11, tm_hour=0, tm_min=0, Tm_se C=0, Tm_wday=3, tm_yday=11, Tm_isdst=-1)"""#structured time-time stamping#parameter is a structured time tuplePrint(Time.mktime (Time.localtime ()))#1515655766.0

The time module 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.