2011/9/10 守株待兔 <1248283...@qq.com>: > how can i convert "Dec 11" into 2011-12?
Read the fine manuals for the `time` or `datetime` modules. http://docs.python.org/library/datetime.html >>> from datetime import datetime >>> datetime.strptime("Dec 11", "%b %y") datetime.datetime(2011, 12, 1, 0, 0) >>> datetime.strptime("Dec 11", "%b %y").strftime("%Y-%m") '2011-12' Note that this code depends on an appropriate locale setting for parsing the month name abbreviations. Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list