python中mktime函数_Python3 time mktime()方法
生活随笔
收集整理的這篇文章主要介紹了
python中mktime函数_Python3 time mktime()方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Python3 time mktime()方法
描述
Python time mktime() 函數執行與gmtime(), localtime()相反的操作,它接收struct_time對象作為參數,返回用秒數來表示時間的浮點數。
如果輸入的值不是一個合法的時間,將觸發 OverflowError 或 ValueError。
語法
mktime()方法語法:
time.mktime(t)
參數
t -- 結構化的時間或者完整的9位元組元素。
返回值
返回用秒數來表示時間的浮點數。
實例
以下實例展示了 mktime() 函數的使用方法:
#!/usr/bin/python3
import time
t = (2016, 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) : 1455699818.000000
asctime(localtime(secs)): Wed Feb 17 17:03:38 2016
總結
以上是生活随笔為你收集整理的python中mktime函数_Python3 time mktime()方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpingAOP
- 下一篇: 代码拿走即用!Python推送内容到公众