Python时间asctime()方法将表示由gmtime()或localtime()返回的时间的元组或struct_time转换为以下形式:“Tue Feb 27 22:21:15 2019”的24个字符的字符串。
语法
以下是asctime()方法的语法 -
time.asctime()
参数
- t - 这是一个
9个元素或struct_time的元组,表示由gmtime()或localtime()函数返回的时间。
返回值
- 此方法返回以下形式的
24个字符的字符串 - “Tue Feb 27 22:21:15 2019”。
示例
以下示例显示了asctime()方法的用法 -
#!/usr/bin/python3
import time
t = time.localtime()
print ("asctime : ",time.asctime(t))
当运行上述程序时,它会产生以下结果 -
asctime : Wed Jun 21 02:58:53 2019
上一篇:
Python日期和时间
下一篇:
Python函数
