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 |