Python中用sleep()方法操作时间的教程,pythonsleep
Python中用sleep()方法操作时间的教程,pythonsleep
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中的strftime()方法的使用,pythonstrftime
- 在Python中操作时间之strptime()方法的使用,pythonstrptime
- 详解Python中time()方法的使用的教程,pythontime
- 在Python中操作时间之tzset()方法的使用教程,pythontzset
- Python判断文件和文件夹是否存在的方法,
- Python常用的文件及文件路径、目录操作方法汇总介绍,
- Python中每次处理一个字符的5种方法,python5种
- Python字符和字符值(ASCII或Unicode码值)转换方法,pythonu
- 在Python中操作列表之List.pop()方法的使用,pythonlist.pop
- Python检测一个对象是否为字符串类的方法,python字符串
评论关闭