Python中用sleep()方法操作时间的教程
作者:goldensun 时间:2023-11-27 10:45:28
mktime()方法是localtime()反函数。它的参数是struct_time或全9元组,它返回一个浮点数,为了兼容时time()。
如果输入值不能表示为有效的时间,那么OverflowError或ValueError错误将被引发。
Syntax
以下是mktime()方法的语法:
time.mktime(t)
参数
t -- 这是struct_time或满9元组。
返回值
此方法返回一个浮点数,对于兼容性time()。
例子
下面的例子显示了mktime()方法的使用。
#!/usr/bin/python
import time
t = (2009, 2, 17, 17, 3, 38, 1, 48, 0)
secs = time.mktime( t )
print "time.mktime(t) : %f" % secs
print "asctime(localtime(secs)): %s" % time.asctime(time.localtime(secs))
当我们运行上面的程序,它会产生以下结果:
time.mktime(t) : 1234915418.000000
asctime(localtime(secs)): Tue Feb 17 17:03:38 2014
标签:Python,time
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python封装成exe的超详细教程
2021-07-30 14:46:20
![](https://img.aspxhome.com/file/2023/3/107813_0s.jpg)
mat矩阵和npy矩阵实现互相转换(python和matlab)
2023-10-19 17:12:02
![](https://img.aspxhome.com/file/2023/7/90877_0s.png)
python subprocess pipe 实时输出日志的操作
2022-10-07 00:39:51
python ftp 按目录结构上传下载的实现代码
2021-01-28 00:38:33
jsp学习之scriptlet的使用方法详解
2023-06-27 11:06:37
python 中的@运算符使用
2023-10-24 22:23:46
![](https://img.aspxhome.com/file/2023/3/124743_0s.png)
基于Python实现微信自动回复功能
2021-10-17 14:01:54
![](https://img.aspxhome.com/file/2023/7/131657_0s.png)
vue 全局引用公共的组件以及公共的JS文件问题
2024-05-29 22:44:46
![](https://img.aspxhome.com/file/2023/5/123035_0s.png)
Yii使用find findAll查找出指定字段的实现方法
2024-05-03 15:13:37
浅谈Python3实现两个矩形的交并比(IoU)
2021-09-06 19:31:56
![](https://img.aspxhome.com/file/2023/7/67247_0s.jpg)
Vue集成lodop插件实现打印功能
2023-07-02 17:01:20
![](https://img.aspxhome.com/file/2023/2/139892_0s.png)
一篇文章带你搞懂Python类的相关知识
2021-06-01 19:31:54
![](https://img.aspxhome.com/file/2023/8/131008_0s.jpg)
Go语言利用ssh连接服务器的方法步骤
2024-04-25 14:59:55
![](https://img.aspxhome.com/file/2023/6/134276_0s.png)
Python实现简单拆分PDF文件的方法
2022-09-27 19:20:37
使用LibTorch进行C++调用pytorch模型方式
2021-09-17 18:56:13
![](https://img.aspxhome.com/file/2023/8/85028_0s.png)
详解uniapp页面跳转URL传参大坑
2023-09-15 09:52:43
ASP判断E-Mail的合法性,以及过滤邮箱字符
2010-05-27 12:23:00
基于Python+Pygame实现经典赛车游戏
2023-09-18 03:57:43
![](https://img.aspxhome.com/file/2023/9/135429_0s.jpg)
全面解析Bootstrap表单使用方法(表单按钮)
2024-05-10 14:08:49
![](https://img.aspxhome.com/file/2023/9/126809_0s.jpg)
完美解决ARIMA模型中plot_acf画不出图的问题
2023-07-13 14:17:34
![](https://img.aspxhome.com/file/2023/1/61761_0s.jpg)