在Python中添加和比较日期时间

4

如何用Python编写这段伪代码?其中'created_date'是一个datetime对象。

if (created_date + 30days) < now:
  print 'valid'
else:
  print 'expired'
1个回答

13
import datetime as DT
if (created_date + DT.timedelta(days=30)) < DT.datetime.now():
    print('valid')
else:
    print('expired')

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接