Python Time asctime() 方法

2024年8月29日 | 1 分钟阅读

asctime() 方法将由 gmtime() 或 localtime() 提供的表示时间的元组或 struct_time 转换为 24 个字符的文本,格式为“Mon May 23 20:22:05 2022”。

asctime() 方法示例

日 月 日 时:分:秒 年

例如

周四 05 22 09:50:43 2022

asctime() 语法

这是 asctime() 方法的语法

参数

t 是一个九元素的元组或 struct_time,它表示由 gmtime() 或 localtime() 函数返回的时间。

返回值

此函数返回一个 24 个字符的字符串,格式为 - 'Mon May 23 20:22:05 2022'。

代码

上面示例代码的输出是

time.asctime(t): Mon May  9 22:37:07 2022