使用datetime.strptime函数可将时间字符串转换为datetime类型数据,见下例:
>>> from datetime import datetime
>>> datetime.strptime(”2009-02-20 15:49:21″,“%Y-%m-%d %H:%M:%S”)
datetime.datetime(2009, 2, 20, 15, 49, 21)
%Y代表年份,%m代表月份…. 详细请参看Python Library Reference
M-OSCAR | Powered by Blogger | Entries (RSS) | Comments (RSS) | Designed by MB Web Design | XML Coded By Cahayabiru.com
0 意見