luofeiyu <[email protected]> writes:
> s="Aug"
>
> how can i change it into 8 with some python time module?
months = (None, # dummy, to start month indices from 1
"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"
)
month_number = months.index(month_abbr) # month_abbr == "Aug"
Note:
- time.strptime(month_abbr, "%b").tm_mon may fail in non-English locale
- list(calendar.month_abbr).index(month_abbr) is also locale-specific
--
Akira
--
https://mail.python.org/mailman/listinfo/python-list