手机
当前位置:查字典教程网 >脚本专栏 >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 获取 Linux 系统信息的代码

Python 字符串操作方法大全

python列表操作使用示例分享

Python 文件操作实现代码

python条件和循环的使用方法

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

使用python 获取进程pid号的方法

Python 时间处理datetime实例

python赋值操作方法分享

精品推荐
分类导航