python 将字符串类型转为时间类型
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'> >>>
http://www.sharejs.com/codes/python/835