清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
python中通过日期转换函数把字符串格式的日期转换成datetime格式的日期格式
time.strptime() converts the string to a struct_time tuple.
time.mktime() converts this tuple into seconds (elasped since epoch, C-style).
datetime.fromtimestamp() converts the seconds to a Python datetime object.
time.strptime() converts the string to a struct_time tuple.
time.mktime() converts this tuple into seconds (elasped since epoch, C-style).
datetime.fromtimestamp() converts the seconds to a Python datetime object.
1 2 3 4 5 6 7 8 | >>> import datetime,time >>> stringDate = "2006-05-18 19:35:00" >>> dt = datetime.datetime.fromtimestamp(time.mktime(time.strptime(stringDate, "%Y-%m-%d %H:%M:%S" ))) >>> print dt 2006 - 05 - 18 19 : 35 : 00 >>> print type(dt) <type 'datetime.datetime' > >>> |