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
hzcOriginal
2020-06-18 15:30:4821741browse

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()) )

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

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!

Statement:
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