Python Time module

Source: Internet
Author: User

Import time

1. A class that represents time. The time range represented is from January 1, 1970 to January 19, 2038.

2, in Python, the way to represent time is: 1) Timestamp: timestamp

2) formatted string

3) Tuple: Struct_time

3. Function of Time

1) time.localtime ([secs]): Converts a timestamp to the struct_time of the current time zone. The secs parameter is empty, whichever is the current time.

The values of the properties (Attribute) are:

Months: 1-12; days: 1-31; hours: 0-23; points: 0-59; seconds: 0-61; week: 0-6;

Days (Tm_yday: The day of the year): 1-366, Summer season (TM_ISDST: Whether summer season): -1,0 (Default is-1)

2) Time.time (): Returns the current timestamp

3) time.mktime (TS): Converts a struct_time to timestamp

4) Time.asctiem ([ts]): A tuple or struct_time representing time is represented in this form: ' Sun June 20 14:34:09:2015 '.

If the argument is empty, the Time.localtime () is passed in as a parameter

5) Time.ctime ([psec]): Converts a timestamp (floating point calculated in seconds) to the form of time.asctime (), when the parameter is empty, the default Time.time () is the parameter, equivalent to Time.asctime ( Time.localtime (secs))

6) Time.strptime (str,fmt= '%a%b%d%h:%m%s%y '): Resolves a time string to a time tuple according to the format of the FMT

Python Time 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.