详解Python中time()方法的使用的教程
作者:goldensun 时间:2022-10-07 16:28:23
time()方法返回时间,在UTC时代以秒表示浮点数。
注意:尽管在时间总是返回作为一个浮点数,并不是所有的系统提供时间超过1秒精度。虽然这个函数正常返回非递减的值,就可以在系统时钟已经回来了两次调用期间返回比以前调用一个较低的值。
语法
以下是time()方法的语法:
参数
NA
返回值
此方法返回的时间,因为时代以秒表示浮点数(在UTC)。
例子
下面的例子显示time()方法的使用。
#!/usr/bin/python
import time
print "time.time(): %f " % time.time()
print time.localtime( time.time() )
print time.asctime( time.localtime(time.time()) )
当我们运行上面的程序,它会产生以下结果:
time.time(): 1234892919.655932
(2014, 2, 17, 10, 28, 39, 1, 48, 0)
Tue Feb 17 10:28:39 2014
标签:Python,time
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
在PyCharm环境中使用Jupyter Notebook的两种方法总结
2021-10-07 08:06:32
![](https://img.aspxhome.com/file/2023/7/112027_0s.jpg)
Python lxml模块的基本使用方法分析
2023-01-31 04:59:40
Python3写入文件常用方法实例分析
2023-08-24 14:44:53
python 中的 super详解
2023-09-07 01:27:35
![](https://img.aspxhome.com/file/2023/3/131563_0s.png)
python 提取文件的小程序
2023-02-08 15:43:39
巧用overflow属性解决中间间距问题
2007-12-08 20:26:00
![](https://img.aspxhome.com/file/UploadPic/200712/8/2007128203846552s.gif)
微信小程序实现录音
2024-04-22 13:25:41
![](https://img.aspxhome.com/file/2023/4/135694_0s.jpg)
java数据库操作类演示实例分享(java连接数据库)
2024-01-28 03:30:20
pytorch中Tensor.to(device)和model.to(device)的区别及说明
2021-10-20 05:26:06
![](https://img.aspxhome.com/file/2023/3/88963_0s.png)
Virtualenv 搭建 Py项目运行环境的教程详解
2023-02-22 04:56:33
![](https://img.aspxhome.com/file/2023/5/62625_0s.gif)
GO必知必会的常见面试题汇总
2023-07-14 01:47:07
![](https://img.aspxhome.com/file/2023/5/90485_0s.jpg)
OpenCV停车场车位实时检测项目实践
2022-09-13 09:37:08
![](https://img.aspxhome.com/file/2023/3/118733_0s.jpg)
浅析Go设计模式之Facade(外观)模式
2023-07-16 19:23:08
MySQL由浅入深探究存储过程
2024-01-14 09:43:04
MySQL回表的性能伤害程度有多大
2024-01-29 10:55:55
python3 循环读取excel文件并写入json操作
2022-11-07 15:40:11
![](https://img.aspxhome.com/file/2023/3/82673_0s.jpg)
TensorFLow用Saver保存和恢复变量
2021-09-18 12:17:17
Python按天实现生成时间范围序列的方法详解
2022-12-31 13:48:45
python sort、sort_index方法代码实例
2022-12-16 00:43:17
python中bottle使用实例代码
2023-07-03 14:21:15
![](https://img.aspxhome.com/file/2023/9/105809_0s.png)