python asctime()方法将一个元组或struct_time表示时间,由gmtime()或localtime() 返回以下形式的24个字符的字符串: 'Tue Feb 17 23:21:05 2009'.

 

python asctime()语法

以下是 asctime() 方法的语法:

time.asctime([t]))

 

python asctime()参数

  • t -- 这是9个元素或struct_time表示,由gmtime()和localtime() 函数返回的时间的元组。

 

python asctime()返回值

此方法返回以下形式的24个字符的字符串: 'Tue Feb 17 23:21:05 2009'.

 

python asctime()示例

下面的例子显示 asctime() 方法的使用。

#!/usr/bin/python3
import time

t = time.localtime()
print (\"asctime : \",time.asctime(t))

当我们运行上面的程序,它会产生以下结果:

asctime :  Mon Feb 15 09:46:24 2016
收藏 打印