Home > Backend Development > Python Tutorial > What is the role of the time.time() function of the time library in python

What is the role of the time.time() function of the time library in python

hzc
Release: 2020-06-18 15:30:48
Original
21742 people have browsed it

What is the role of the time.time() function of the time library in python

#What is the role of the time.time() function of the time library in python?

Function: Python time time() returns the timestamp of the current time (the number of floating point seconds elapsed since the 1970 epoch).

time() method syntax: time.time()

Parameters NA.

Return value Returns the timestamp of the current time (the number of floating point seconds elapsed since the 1970 epoch)

Example

The following example shows how to use the time() function:

#!/usr/bin/python
import time

print "time.time(): %f " %  time.time()
print time.localtime( time.time() )
print time.asctime( time.localtime(time.time()) )
Copy after login

The output result of the above example is:

time.time(): 1234892919.655932
(2009, 2, 17, 10, 48, 39, 1, 48, 0)
Tue Feb 17 10:48:39 2009
Copy after login

Recommended tutorial: "Python Tutorial"

The above is the detailed content of What is the role of the time.time() function of the time library in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template