Python time localtime()方法

2021-09-06 15:15 更新

Python time localtime()方法


描述

Python time localtime() 函数类似gmtime(),作用是格式化时间戳为本地的时间。 如果sec参数未输入,则以当前时间为转换标准。 DST (Daylight Savings Time) flag (-1, 0 or 1) 是否是夏令时。

语法

localtime()方法语法:

time.localtime([ sec ])

参数

  • sec -- 转换为time.struct_time类型的对象的秒数。

返回值

该函数没有任何返回值。

实例

以下实例展示了 localtime() 函数的使用方法:

#!/usr/bin/python
import time

print "time.localtime() : %s" % time.localtime()

以上实例输出结果为:

time.localtime() : (2009, 2, 17, 17, 3, 38, 1, 48, 0)
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号