有用python代码片断
2016年1月14日
没有评论
1 日期与字符串转换
#convert a string to a datetime object
from datetime import datetime
date_obj = datetime.strptime(‘May 29 2015 2:45PM’, ‘%B %d %Y %I:%M%p’)
#converting datetime object to a formatted string
from datetime import datetime
date_obj = datetime.now()
date_string = date_obj.strftime(‘%B %d %Y %I:%M%p’)
阅读全文…
近期评论