Python Learning Notes--time module built-in functions and examples

Source: Internet
Author: User
Tags local time

1 Import Time2 #Timestamp : Total number of seconds 1970.1.1.08:00:00 up to now3 #-----------------------------Time module built-in functions-----------------------------4 #Time.altzone #返回格林威治西部的夏令时地区的偏移秒数5 Print("offset seconds for daylight saving time zone: Time.altzone%d"%Time.altzone)6 7 Print("\ n-----------------split line-----------------\ n")8 9 #Time.localtime () returns a time tuple of local time, if the timestamp is passed, returns the time tuple of the corresponding timestampTen Print("time.localtime ():", Time.localtime ()) One Print("Time.lcoaltime (1.0):", Time.localtime (1.0)) A  - Print("\ n-----------------split line-----------------\ n") -  the #Time.asctime Accept Time tuple ([tupletime]) return "Tue Dec 11 18:07:14 2008" (December 11, 2008 Tuesday 18:07 14 seconds) - Print("Time.asctime (Time.localtime ()):%s"%Time.asctime (Time.localtime ())) -  - Print("\ n-----------------split line-----------------\ n") +  - #Time.clock () returns the current CPU time using the number of seconds calculated by the yo floating point.  + Print("Time.clock ()%s"%Time.clock ()) A  at Print("\ n-----------------split line-----------------\ n") -  - #time.ctime ([secs]) functions equivalent to Asctime (localtime (secs)), parameter is equivalent to Asctime () - Print("time.ctime ():", Time.ctime ()) -  - Print("\ n-----------------split line-----------------\ n") in  - #time.gmtime ([secs]) accepts a timestamp (the number of floating-point seconds elapsed in the 1970 ERA), returning the time tuple under Greenwich Astronomical TIME to Print("time.gmtime ([secs])", Time.gmtime ()) +  - Print("\ n-----------------split line-----------------\ n") the  * #Time.mktime (t) accept time-tuple return timestamp $ Print("Time.mktime (Time.localtime ()):", Time.mktime (Time.localtime ()))Panax Notoginseng  - Print("\ n-----------------split line-----------------\ n") the  + #time.sleep (secs) Deferred call thread run, secs refers to number of seconds ATime.sleep (10) the  + Print("\ n-----------------split line-----------------\ n") -  $ #Time.strftime (Fmt[,tupletime]) accepts a time tuple, returns a string, formatted as determined by the FMT $ Print(Time.strftime ("%y-%m-%d%h:%m:%s", Time.localtime ())) -  - Print("\ n-----------------split line-----------------\ n") the  - #Time.time () returns the current timestamp (the number of floating-point seconds elapsed after the 1970 era)Wuyi Print("time.time ():", Time.time ())

Python Learning Notes--time module built-in functions and examples

Related Article

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.