手机
当前位置:查字典教程网 >脚本专栏 >python >Python中的localtime()方法使用详解
Python中的localtime()方法使用详解
摘要:localtime()方法类似gmtime()方法,但它转换秒数为本地时间。如果不设置秒时或None,所返回的当前时间使用time()方法。...

localtime()方法类似gmtime()方法,但它转换秒数为本地时间。如果不设置秒时或None,所返回的当前时间使用time()方法。在dst标志被设置为1时,夏令时适用于给定的时间。

语法

以下是localtime()方法的语法:

time.localtime([ sec ])

参数

sec -- 这是秒数转换成结构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)

【Python中的localtime()方法使用详解】相关文章:

使用Python进行稳定可靠的文件操作详解

Python的print用法示例

python 不关闭控制台的实现方法

python使用mysqldb连接数据库操作方法示例详解

python列表与元组详解实例

Python中zip()函数用法实例教程

Python中的魔法方法深入理解

Python 文件读写操作实例详解

Python去掉字符串中空格的方法

Python ZipFile模块详解

精品推荐
分类导航