strptime not strict enough
Lie Ryan
lie.1296 at gmail.com
Wed Dec 16 05:03:01 EST 2009
On 12/15/2009 10:30 AM, Tobias Weber wrote:
> Hi,
> despite the directives for leading zero stime.strptime('09121',
> '%y%m%d') returns the first of December. Shouldn't it raise ValueError?
>
> Where do I get strict date parsing?
A bit hackish perhaps, but maybe you can check for the date's length:
date = '09121'
if len(date) == 6 and time.strptime(date, format):
...
More information about the Python-list
mailing list