How to use the time () method in Python

Source: Internet
Author: User

How to use the time () method in Python

This article describes how to use the time () method in Python. It is the basic knowledge of getting started with Python. For more information, see

The return time of the time () method, expressed in seconds in UTC time.

Note: although it is always returned as a floating point number in time, not all systems provide a precision of over 1 second. Although this function normally returns a non-decreasing value, it can return a lower value than the previous call when the system clock has returned two calls.

Syntax

The syntax of the time () method is as follows:

Parameters

NA

Return Value

The time returned by this method, because the time in seconds represents a floating point (in UTC ).

Example

The following example shows how to use the time () method.

?

1

2

3

4

5

6

#! /Usr/bin/python

Import time

 

Print "time. time (): % f" % time. time ()

Print time. localtime (time. time ())

Print time. asctime (time. localtime (time. time ()))

When we run the above program, it will produce the following results:

?

1

2

3

Time. time (): 1234892919.655932

(2014, 2, 17, 10, 28, 39, 1, 48, 0)

Tue Feb 17 10:28:39 2014

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.