Python time asctime()方法

2021-09-06 15:13 更新

Python time asctime()方法


描述

Python time asctime() 函數(shù)接受時間元組并返回一個可讀的形式為"Tue Dec 11 18:07:14 2008"(2008年12月11日 周二18時07分14秒)的24個字符的字符串。

語法

asctime()方法語法:

time.asctime([t]))

參數(shù)

  • t -- 9個元素的元組或者通過函數(shù) gmtime() 或 localtime() 返回的時間值。

返回值

返回一個可讀的形式為"Tue Dec 11 18:07:14 2008"(2008年12月11日 周二18時07分14秒)的24個字符的字符串。

實例

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

#!/usr/bin/python
import time

t = time.localtime()
print "time.asctime(t): %s " % time.asctime(t)

以上實例輸出結(jié)果為:

time.asctime(t): Tue Feb 17 09:42:58 2009
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號