Python的时间转换
来源:互联网 发布:仿链家房产源码 编辑:程序博客网 时间:2024/05/22 03:27
要进行时间转换,在python里面是非常简单的,这里会使用到 time 模块里的 strptime() 和 strftime()。
下面我们用实例来演示一下:
strptime() 根据你指定的格式控制字符串解读日期,
strftime() 则根据你指定的格式控制字符串输出日期。
比如,把 “01-Sep-14 13:30” 格式转换成 “14--12 10:06:00” 格式:
1
2
3
4
5
6
7
8
9
10
11
>>>
from
time
import
strptime, strftime
>>> dateStr
=
'01-Sep-14 13:30'
>>> parseStr
=
strptime( dateStr,
'%d-%b-%y %H:%M'
)
>>> coverted
=
strftime(
'%Y/%m/%d %H:%M'
, parseStr )
>>>
>>> parseStr
time.struct_time(tm_year
=
2014
, tm_mon
=
9
, tm_mday
=
1
, tm_hour
=
13
, tm_min
=
30
, tm_sec
=
0
, tm_wday
=
0
, tm_yday
=
244
, tm_isdst
=
-
1
)
>>>
>>> coverted
'2014/09/01 13:30'
>>>
0 0
- Python的时间转换
- python的时间戳转换
- Python的UTC时间转换
- python时间转换的方法
- Python时间格式的转换
- python转换时间戳和日期时间格式的转换
- python进行时间和秒的转换
- python时间与字符串之间的转换
- Python 时间与秒数的转换
- python之常用的时间格式转换
- Python- 时间格式的相互转换
- python-时间戳转换时间
- python时间和时间戳之间的转换
- python中时间、日期、时间戳之间的转换
- python——时间与时间戳之间的转换
- python 时间戳与时间之间的转换
- python 爬虫中时间和时间戳的互相转换
- Python的时间字符串,不同格式,时间戳之间转换
- 线程编程常见API简介(上)
- 线程编程常见API简介(中)
- 【树状数组】 HDU 4991 Ordered Subsequence
- 线程编程常见API简介(下)
- C++ 中如何设计 final 类
- Python的时间转换
- 使用 acl 库编写发送邮件的客户端程序
- acl 服务器模块的部署
- Android显式意图、隐式意图、意图过滤器(intent-filter)、意图间传值
- 剑指offer——数组中只出现一次的数字
- acl服务器模块的部署--示例
- 使用 acl 库 rpc 功能类实现 阻塞任务过程与MFC 界面过程分离
- 使用 acl 生成向导快速创建服务器程序
- boost::bind 绑定成员函数