asctime()方法將一個元組或struct_time表示時間,由gmtime()或localtime() 返回以下形式的24個字元的字串: 'Tue Feb 17 23:21:05 2009'.
語法
以下是 asctime() 方法的語法:
time.asctime([t]))
參數
-
t -- 這是9個元素或struct_time表示,由gmtime()和localtime() 函數返回的時間的元組。
返回值
此方法返回以下形式的24個字元的字串: 'Tue Feb 17 23:21:05 2009'.
示例
下麵的例子顯示 asctime() 方法的使用。
#!/usr/bin/python3 import time t = time.localtime() print ("asctime : ",time.asctime(t))
當我們運行上面的程式,它會產生以下結果:
asctime : Mon Feb 15 09:46:24 2016
上一篇:
Python3字典
下一篇:
Python3日期和時間