【发布时间】:2013-01-30 14:57:09
【问题描述】:
我正在尝试拆分日期时间...存储日期效果很好,但每当我尝试存储时间时都会出错。
以下代码有效:
datetime = tweet.date.encode( 'ascii', 'ignore')
struct_date = time.strptime(datetime, "%a, %d %b %Y %H:%M:%S +0000")
date = time.strftime("%m/%d/%Y")
但是如果我添加以下行,我会得到一个错误:
time = time.strftime("%H:%M:%S")
AttributeError: 'str' 对象没有属性 'strptime'
【问题讨论】:
标签: python datetime time strptime