手机
当前位置:查字典教程网 >脚本专栏 >python >在Python操作时间和日期之asctime()方法的使用
在Python操作时间和日期之asctime()方法的使用
摘要:asctime()方法将一个元组或struct_time表示的时间返回gmtime()或localtime(),以下列格式的24个字符的字符...

asctime()方法将一个元组或struct_time表示的时间返回gmtime()或localtime(),以下列格式的24个字符的字符串:“Tue Feb 17 23:21:05 2015”。

语法

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

time.asctime([t]))

参数

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

返回值

此方法返回以下形式的24个字符的字符串:“Tue Feb 17 23:21:05 2015”。

例子

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

#!/usr/bin/python import time t = time.localtime() print "time.asctime(t): %s " % time.asctime(t)

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

time.asctime(t): Tue Feb 17 09:42:58 2014

【在Python操作时间和日期之asctime()方法的使用】相关文章:

Python获取当前时间的方法

python条件和循环的使用方法

python实现问号表达式(?)的方法

python中的sort方法使用详解

简单文件操作python 修改文件指定行的方法

Python 文件操作实现代码

Python中文件遍历的两种方法

Python 时间操作例子和时间格式化参数小结

python列表操作使用示例分享

python类参数self使用示例

精品推荐
分类导航