Python Learning Note 07

Source: Internet
Author: User

?

Time:

Tickets

Time tuple

Formatted time

Calendar

Import Time

Tickets = time. Time ()

Print Tickets

Print time. localtime () #本地时间元组

Print time. Gmtime () #UTC时间元组

Print time. Asctime (timelocaltime ())

?

Importcalendar

Printcalendar. Month (2015,8)

?

?

CPU clock: Clock

Sleeping: Sleep

Creation Time: Mktime

#clock & Sleep

Import Time

def procedure ():

Time. Sleep (0.5)

?

T0 = time. Clock ()

Procedure ()

Print time. Clock ()-T0

#mktime

t = (2009, 2, 17, 17, 3, 38, 1, 48, 0)

secs = time. Mktime (t)

Print"Time.mktime (t):%f" % secs

Print time. localtime (secs)

?

DateTime: A datetime similar to C #

Importdatetime

DT = datetime. DateTime(2015,8,11,10,31,55)

Print DT

Print Dt.hour

Print Dt.second

?

Delta = datetime. Timedelta(hours=5)

Print dt + Delta

Print Dt-delta

?

?

FromdatetimeImportdatetime

Format = "Output-%y-%m-%d-%h%m%s.txt"

str = "Output-1997-12-23-030000.txt"

t = datetime. Strptime (str, format)

?

FromdatetimeImport *

Printdatetime. Now ()

Printdate. Today ()

Python Learning note

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.