码迷,mamicode.com
首页 > 其他好文 > 详细

time模块

时间:2018-10-13 22:51:04      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:asc   alt   夏令时   mtime   form   time模块   string   格式   str   

time模块提供时间相关函数。

time.sleep(secs) 线程挂起指定秒
time.gmtime([secs]) 将时间戳转为UTC struct_time对象,并且夏令时参数始终为0
time.localtime([secs]) 同gmtime,转换为本地 struct_time对象,若夏令时可用则参数设置为1
time.mktime(t) localtime的反函数,将struct_time对象转为时间戳
time.asctime([t]) 将struct_time对象转换为格式化字串显示,若不提供参数则由localtime生成
time.strftime(format[,t]) 将struct_time对象转换为指定格式字串显示,可用格式如下
%a 简写工作日,如周四->Thu
%A 全名工作日,如周四->Thursday
%b, %B 月份名
%c 同asctime显示
%d 每月几号
%H, %I 24, 12小时制
%j 每年第几天
%m 月份
%M 分钟
%p AM/PM
%S 秒数
%U 每年第几周
%w, %W 每周第几天, 每年第几周
%x, %X 月日年, 时分秒
%y, %Y 简单年份, 完整年份
%Z 时区,时区名称
%% %号
time.strptime(string[, format]) 将时间字串转换为struct_time对象

time模块

标签:asc   alt   夏令时   mtime   form   time模块   string   格式   str   

原文地址:https://www.cnblogs.com/ikct2017/p/9784364.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!