在Python操作时间和日期之asctime()方法的使用
asctime()方法将一个元组或struct_time表示的时间返回gmtime()或localtime(),以下列格式的24个字符的字符串:“TueFeb1723:21:052015”。
语法
以下是asctime()方法的语法:
time.asctime([t]))
参数
- t--这是9个元素或struct_time元组表示所返回gmtime的()或localtime()函数的时间。
返回值
此方法返回以下形式的24个字符的字符串:“TueFeb1723:21:052015”。
例子
下面的例子显示了asctime()方法的使用。
#!/usr/bin/python importtime t=time.localtime() print"time.asctime(t):%s"%time.asctime(t)
当我们运行上面的程序,它会产生以下结果:
time.asctime(t):TueFeb1709:42:582014
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短