asctime()方法將一個元組或struct_time表示的時間返回gmtime()或localtime(),以下列格式的24個字符的字符串:“Tue Feb 17 23:21:05 2015”。
語法
以下是asctime()方法的語法:
1
|
time.asctime([t])) |
參數
- t -- 這是9個元素或struct_time元組表示所返回gmtime的()或localtime()函數的時間。
返回值
此方法返回以下形式的24個字符的字符串:“Tue Feb 17 23:21:05 2015”。
例子
下面的例子顯示了asctime()方法的使用。
1
2
3
4
5
|
#!/usr/bin/python import time t = time.localtime() print "time.asctime(t): %s " % time.asctime(t) |
當我們運行上面的程序,它會產生以下結果:
1
|
time.asctime(t): Tue Feb 17 09 : 42 : 58 2014 |