手机
当前位置:查字典教程网 >脚本专栏 >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操作MySQL数据库的方法分享

python条件和循环的使用方法

Python 字符串操作方法大全

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

在python中的socket模块使用代理实例

python函数返回多个值的示例方法

python操作日期和时间的方法

讲解python参数和作用域的使用

使用 Python 获取 Linux 系统信息的代码

python迭代器的使用方法实例

精品推荐
分类导航