Python Time Module Timing processing

Source: Internet
Author: User

Import time
Import re

Print Time.time ()
Print Time.localtime ()
A = ' tm_year=2016, tm_mon=5, tm_mday=28, tm_hour=6, tm_min=51, tm_sec=14, tm_wday=5, tm_yday=149, tm_isdst=0 '
b = Re.findall (' \d+ ', a)
Print B
c = []
For Tup in B:
t = Int (TUP)
C.append (t)
c = Tuple (c)
Print type (c)
Print C
# c = (2016, 5, 28, 6, 51, 14, 5, 149, 0)
Print Time.mktime (c)
Print Time.mktime (Time.localtime (1464389474.0)) # Tuple converted to timestamp, struct_time---> Timestamp
Print Time.localtime (1464389474.0)
Print Time.gmtime (1464389474.0) # Timestamp converted to tuple, timestamp--->struct_time
Print Time.strftime ('%y-%m-%d%h:%m:%s:%a:%b:%c:%j%p%u%w%w%x ', Time.localtime (1464389474.0))
Print Time.strftime ('%y-%m-%d%h:%m:%s ') # struct_time---> formatted string
Print Time.strptime (' 2016-05-28 06:51:14 ', '%y-%m-%d%h:%m:%s ') #格式化字符串--->struct time

#元组和字符串无法直接相互转化

#datetime

Python Time Module Timing processing

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.