-1
我想创建一些基于Twitter处理集的其他一些代码的约束。Python&Tweepy - 如何比较和更改时间。
我有下面的代码的问题,因为:
TypeError: can't compare datetime.datetime to str
看来,即使我已经改变LAST_POST为datetime对象最初,当我把它比作datetime.datetime.today()是转换为字符串。是的,我已检查确保Last_post正确转换。我不确定发生了什么事。帮帮我?
for handle in handles:
try:
user = api.get_user(handle)
#print json.dumps(user, indent = 4)
verified = user["verified"]
name = user['name']
language = user['lang']
follower_count = user['followers_count']
try:
last_post = user['status']['created_at']
last_post = datetime.strptime(last_post, '%a %b %d %H:%M:%S +0000 %Y')
except:
last_post = "User has not posted ever"
location = user['location']
location_ch = location_check(location)
if location_ch is not "United States":
location_output.append(False)
else:
location_output.append(True)
new_sum.append(follower_count)
if language is not "en":
lang_output.append(False)
else:
lang_output.append(True)
if datetime.datetime.today() - datetime.timedelta(days=30) > last_post:
recency.append(False)
else:
recency.append(True)