欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

在Python中操作時(shí)間之mktime()方法的使用教程

 更新時(shí)間:2015年05月22日 12:09:07   投稿:goldensun  
這篇文章主要介紹了在Python中操作時(shí)間之mktime()方法的使用教程,是Python入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下

 mktime()方法是localtime()反函數(shù)。它的參數(shù)是struct_time或全9元組,它返回一個(gè)浮點(diǎn)數(shù),為了兼容時(shí)time()。

如果輸入值不能表示為有效的時(shí)間,那么OverflowError或ValueError錯(cuò)誤將被引發(fā)。
Syntax

以下是mktime()方法的語(yǔ)法:

time.mktime(t)

參數(shù)

  •     t -- 這是struct_time或滿9元組。

返回值

此方法返回一個(gè)浮點(diǎn)數(shù),對(duì)于兼容性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))

當(dāng)我們運(yùn)行上面的程序,它會(huì)產(chǎn)生以下結(jié)果:

time.mktime(t) : 1234915418.000000
asctime(localtime(secs)): Tue Feb 17 17:03:38 2014


相關(guān)文章

最新評(píng)論