Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 python 获取上个月和上一年的数据。是否可以使用 datetime 模块获取它
我想像下面的例子一样得到它
current: 2012-03 prev 2012-02 current: 2012-01 prev 2011-12
采用
date(2012,3,1)+relativedelta(years=-1)
见http://labix.org/python-dateutil