##language:zh #pragma section-numbers off ##含有章节索引导航的 ZPyUG 文章通用模板 <> ## 默许导航,请保留 <> = 110616 月度列表生成? = ##startInc == 问题 == 2011/6/16 cougar cougar : {{{ > 知道历史上某个时间,比如:2008-08 > 得到目前2011-06之间年号和月份的列表 > 2008-08 > 2008-09 > 。。。 > 。。。 > 2011-05 > 2011-06 > 列表解析还是for? > }}} == Leo Jay == {{{ python.leojay@gmail.com 发件人当地时间 发送时间 15:37 (GMT+08:00)。发送地当前时间:下午3:51。 ✆ 回复 python-cn@googlegroups.com 发送至 python-cn@googlegroups.com 日期 2011年6月16日 下午3:37 主题 Re: [CPyUG] 求个代码,关于年月 }}} {{{ #!python >>> ['%d-%02d' % (i/12, (i%12)+1) for i in xrange(2008*12+8-1, 2011*12+6)] ['2008-08', '2008-09', '2008-10', '2008-11', '2008-12', '2009-01', '2009-02', '2009-03', '2009-04', '2009-05', '2009-06', '2009-07', '2009-08', '2009-09', '2009-10', '2009-11', '2009-12', '2010-01', '2010-02', '2010-03', '2010-04', '2010-05', '2010-06', '2010-07', '2010-08', '2010-09', '2010-10', '2010-11', '2010-12', '2011-01', '2011-02', '2011-03', '2011-04', '2011-05', '2011-06'] }}} ##endInc ---- '''反馈''' 创建 by -- ZoomQuiet [<>]