Python Learning _time Module use

Source: Internet
Author: User
Tags local time

#!/usr/bin/python

#-*-Encoding=utf-8-*-

#DATE: 2018-05-12

""" %y  Two-digit year 00-99%y four-digit year 000-9999%m month 01-12%d   day 01-31%h  Hour (24-hour system that 0~23 point)%I    Hour (12-hour 01~12)%M  Minutes%s   seconds "" "
Print('= = Summary = =')Print('One, Time module') Time.time ()#gets the timestamp of the current timeTime.gmtime ()#gets the format time of international UTC (Tm_year=2018,tm_mon=5 ... ), or you can change the timestamp to Struc_time timeTime.localtime ()#gets the local time format time (struct_time)#Note:#format time so we know the current time is the day of the week or the first of this year#Timestamps are typically used to calculate the time differenceTime.strftime (format="', p_tuple="')#time to format struc_time as a custom format#Print (Time.strftime ('%y-%m-%d%h%m%s ', Time.localtime ()))##2018 -05-12 092320Time.strptime (string="', format="')#formats a specific time as a formatted time Struc_time#Print (Time.strptime (' 2018/05/10 ', '%y/%m/%d '))##time. Struct_time (tm_year=2018, tm_mon=5, tm_mday=10, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=130, tm_ Isdst=-1)Time.clock ()#gets the time that the CPU run program worked, but sleep does not count when the CPU is not workingTime.asctime (p_tuple="')#format Struk_time as a string time such as: ' Sat June 16:26:11 1998 '.Time.ctime (Seconds=none)#format seconds as time stamps as String time: '-->thu Jan 1 08:05:00 1970Time.mktime (p_tuple="')#struc_time Time is gmtime (), localtime () is formatted as a timestampTime.sleep (seconds="')#How many seconds are paused

 

Python Learning _time Module use

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.