Python time asctime()方法
描述
Python time asctime() 函數接受時間元組並返回一個可讀的形式為"Tue Dec 11 18:07:14 2008"(2008年12月11日 週二18時07分14秒)的24個字元的字串。
語法
asctime()方法語法:
time.asctime([t]))
參數
- t -- 9個元素的元組或者通過函數 gmtime() 或 localtime() 返回的時間值。
返回值
返回一個可讀的形式為"Tue Dec 11 18:07:14 2008"(2008年12月11日 週二18時07分14秒)的24個字元的字串。
實例
以下實例展示了 asctime()函數的使用方法:
#!/usr/bin/python import time t = time.localtime() print "time.asctime(t): %s " % time.asctime(t)
以上實例輸出結果為:
time.asctime(t): Tue Feb 17 09:42:58 2009