time.strptime(str,fmt=‘%a %b %d %H:%M:%S %Y‘)

收藏:0   阅读:34

Python time strptime()方法


描述

Python time strptime() 函数根据指定的格式把一个时间字符串解析为时间元组。

语法

strptime()方法语法:

time.strptime(string[, format])

参数

返回值

返回struct_time对象。

说明

python中时间日期格式化符号:

实例

以下实例展示了 strptime() 函数的使用方法:

#!/usr/bin/python
import time

struct_time = time.strptime("30 Nov 00", "%d %b %y")
print "returned tuple: %s " % struct_time

以上实例输出结果为:

returned tuple: (2000, 11, 30, 0, 0, 0, 3, 335, -1)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!