手机
当前位置:查字典教程网 >脚本专栏 >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中文件遍历的两种方法

python数据结构之二叉树的遍历实例

Python 时间处理datetime实例

python赋值操作方法分享

Python程序设计入门(3)数组的使用

Python操作Mysql实例代码教程在线版(查询手册)

python中的sort方法使用详解

精品推荐
分类导航