Python中的localtime()方法使用详解,pythonlocaltime
Python中的localtime()方法使用详解,pythonlocaltime
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中操作时间之mktime()方法的使用教程,pythonmkti
- Python3读取UTF-8文件及统计文件行数的方法,
- Python3处理文件中每个词的方法,
- python实现数组插入新元素的方法,python新元素
- python实现的简单抽奖系统实例,python抽奖实例
- linux下python抓屏实现方法,python抓屏
- python使用reportlab实现图片转换成pdf的方法,
- Python中用sleep()方法操作时间的教程,pythonsleep
- 详解Python中的strftime()方法的使用,pythonstrftime
- 在Python中操作时间之strptime()方法的使用,pythonstrptime
评论关闭