如果输入值不能表示为有效的时间,那么OverflowError或ValueError错误将被引发。
Syntax
以下是mktime()方法的语法:
time.mktime(t)
参数
返回值
此方法返回一个浮点数,对于兼容性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) : 12349118.000000 asctime(localtime(secs)): Tue Feb 17 17:03:38 2014
Copyright © 2019- sarr.cn 版权所有 赣ICP备2024042794号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务