各位用户为了找寻关于在Python操作时间和日期之asctime()方法的使用的资料费劲了很多周折。这里教程网为您整理了关于在Python操作时间和日期之asctime()方法的使用的相关资料,仅供查阅,以下为您介绍关于在Python操作时间和日期之asctime()方法的使用的详细内容

 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