您可以使用datetime.datetime.strptime(...)
做轉換。就像這樣:
>>> datetime.datetime.strptime('07_Nov_2011', '%d_%b_%Y').date()
datetime.date(2011, 11, 7)
您可以打印所有像這樣的東西中間日期:
>>> start_date = '07_Nov_2011'
>>> end_date = '10_Jan_2012'
>>>
>>> first = datetime.datetime.strptime(start_date, '%d_%b_%Y')
>>> last = datetime.datetime.strptime(end_date, '%d_%b_%Y')
>>> for i in xrange((last-first).days):
... print (first+datetime.timedelta(i)).strftime('%d_%b_%Y')
...
07_Nov_2011
08_Nov_2011
09_Nov_2011
10_Nov_2011
11_Nov_2011
etc.