python-Time Module-time

Source: Internet
Author: User
Tags local time

Time

Time processing module, the usual time is the East Eight district Beijing (Shanghai) time, in UTC standard Time + 8 hours

Gets the timestamp . time

# January 1, 1970 00:00, until now time

Import Timeprint (Time.time ())

Gets the local time . LocalTime

# You can also pass in a timestamp to convert to a time stamp corresponding to the time

Import Timeprint (Time.localtime ()) Print (Time.localtime (15279905.9574919))

How many seconds to suspend the thread, and the analog IO jam . Sleep

Import Timetime.sleep (2) print ("Beimenchuixue")

  

Format time . strftime

# Common year%Y month%m day%d%H minutes%m seconds%s

Import Timeprint (Time.strftime ("%y-%m-%d%h:%m:%s"), Time.localtime ())

Specifies the format resolution time . Strptime

# Convert to localtime time format

Import Timeprint (Time.strptime ("2017-5-4", "%y-%m-%d"))

Convert to timestamp . Mktime

# Incoming LocalTime time format, Federated Strptime use

Import Timeprint (Time.mktime (Time.strptime ("2017-5-4", "%y-%m-%d"))

 

python-Time Module-time

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.