Python Common Module series

Source: Internet
Author: User

1. Time Module
ImportTime,datetime#print (Time.time ()) #时间戳#Print (Time.strftime ("%y-%m-%d%x")) #格式化时间#print (Time.localtime ()) #本地的struct_time#print (Time.gmtime ()) #本地的utc时间#print (Time.ctime ()) #英文日期#time plus minusPrint(Datetime.datetime.now ())#Displays the current time in millisecondsPrint(Datetime.date.fromtimestamp (Time.time ()))#turn timestamps directly into date formatsPrint(Datetime.datetime.now () + Datetime.timedelta (3))#Show now time plus three daysPrint(Datetime.datetime.now () + Datetime.timedelta (-3))#show current time minus three daysPrint(Datetime.date.fromtimestamp (Time.time ()) + Datetime.timedelta (3))#Current time rounding plus threePrint(Datetime.date.fromtimestamp (Time.time ()) + Datetime.timedelta (-3))#Current time rounding minus threePrint(Datetime.datetime.now () + Datetime.timedelta (hours=3))#Show now time plus three hoursPrint(Datetime.datetime.now ()-Datetime.timedelta (hours=3))#show current time minus three hoursPrint(Datetime.datetime.now () + Datetime.timedelta (minutes=30))#Show now time plus 30 points#Time SubstitutionNow_time =Datetime.datetime.now ()Print(Now_time.replace (minute=3,hour=2))

    • Where the computer knows time can only be ' timestamp ' format, and the programmer can deal with or say that human can understand the time is: ' Formatted time string ', ' structured time ', so there is a conversion relationship

Python Common Module series

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.