Python time strftime()方法
来源:互联网 发布:万得数据 编辑:程序博客网 时间:2024/05/16 04:46
Python time strftime()方法
描述
Python time strftime() 函数接收以时间元组,并返回以可读字符串表示的当地时间,格式由参数format决定。
语法
strftime()方法语法:
time.strftime(format[, t])
参数
- format -- 格式字符串。
- t -- 可选的参数t是一个struct_time对象。
返回值
返回以可读字符串表示的当地时间。
说明
python中时间日期格式化符号:
- %y 两位数的年份表示(00-99)
- %Y 四位数的年份表示(000-9999)
- %m 月份(01-12)
- %d 月内中的一天(0-31)
- %H 24小时制小时数(0-23)
- %I 12小时制小时数(01-12)
- %M 分钟数(00=59)
- %S 秒(00-59)
- %a 本地简化星期名称
- %A 本地完整星期名称
- %b 本地简化的月份名称
- %B 本地完整的月份名称
- %c 本地相应的日期表示和时间表示
- %j 年内的一天(001-366)
- %p 本地A.M.或P.M.的等价符
- %U 一年中的星期数(00-53)星期天为星期的开始
- %w 星期(0-6),星期天为星期的开始
- %W 一年中的星期数(00-53)星期一为星期的开始
- %x 本地相应的日期表示
- %X 本地相应的时间表示
- %Z 当前时区的名称
- %% %号本身
实例
以下实例展示了 strftime() 函数的使用方法:
#!/usr/bin/pythonimport timet = (2009, 2, 17, 17, 3, 38, 1, 48, 0)t = time.mktime(t)print time.strftime("%b %d %Y %H:%M:%S", time.gmtime(t))
以上实例输出结果为:
Feb 17 2009 09:03:38
阅读全文
0 0
- Python time strftime()方法
- Python time strftime()方法
- Python time strftime()方法
- Python time strftime()方法
- Python-time.strftime
- Python:time, strftime和strptime
- Python:time, strftime和strptime
- Python time 函数time.strftime()简介
- Python 常用函数time.strftime()简介
- Python中time, strftime和strptime
- Time#strftime
- python使用 time.strftime() 命名文件名包含当前时间
- Linux time(),strftime()函数
- strftime time server
- python 中strftime用法
- Python中的strftime函数
- Python中的strftime()
- python datetime strftime
- iOS开发之UIAlertController的使用
- liunx WordPress 安装(超详细)
- hash_map
- 把一个c类的网络地址192-168-1-0划分为6个子网,请计算出...
- 欢迎使用CSDN-markdown编辑器
- Python time strftime()方法
- vuex下state数据的存储
- 二叉树求序
- time.h 详细介绍
- Lua 开篇
- vim与vi的区别,及常用操作,有查找关键词,向上向下翻页,快速跳到一行首末尾,设置取消行号,撤销编辑
- SVN显示提交时间,提交人等信息
- iFunk:用户全方位享乐体验的升级
- 学习C++要做笔记1(引用)