【Python】Python time mktime()方法
2017-09-29 15:51
411 查看
描述
Python time mktime() 函数执行与gmtime(), localtime()相反的操作,它接收struct_time对象作为参数,返回用秒数来表示时间的浮点数。
如果输入的值不是一个合法的时间,将触发 OverflowError 或 ValueError。
语法
mktime()方法语法:
time.mktime(t)
参数
- t -- 结构化的时间或者完整的9位元组元素。
返回值
返回用秒数来表示时间的浮点数。
实例
以下实例展示了 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 2009
相关文章推荐
- Python time mktime()方法
- Python time mktime()方法
- 【LeetCode】【Python解决问题的方法】Best Time to Buy and Sell Stock II
- 详解Python中time()方法的使用的教程
- php中time()和mktime()方法的区别
- Python time strftime()方法
- php中time()和mktime()方法的区别
- Python time strptime()方法
- Python3基础 用索引值访问time方法返回来的元组中的年月日时分秒
- python 中datetime、time、calendar模块中常用的方法
- python time datetime模块使用方法记录
- Python的time模块中的常用方法整理
- Python time strftime()方法
- Python time strftime()方法
- time,datetime------python操作日期和时间的方法
- Python中time,datetime模块的常见使用方法
- Python基于time模块求程序运行时间的方法
- Python time strptime()方法
- python学习笔记(time.time方法)
- 在Python中操作时间之mktime()方法的使用教程