Latest web development tutorials

Python time localtime()方法

描述

Python time localtime() 函數類似gmtime(),作用是格式化時間戳為本地的時間。 如果sec參數未輸入,則以當前時間為轉換標準。 DST (Daylight Savings Time) flag (-1, 0 or 1) 是否是夏令時。

語法

localtime()方法語法:

time.localtime([ sec ])

參數

  • sec -- 轉換為time.struct_time類型的對象的秒數。

返回值

該函數沒有任何返回值。

實例

以下實例展示了localtime() 函數的使用方法:

#!/usr/bin/python
import time

print "time.localtime() : %s" % time.localtime()

以上實例輸出結果為:

time.localtime() : (2009, 2, 17, 17, 3, 38, 1, 48, 0)