Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datetime in python ridiculous error [duplicate]

When I type

datetime.date(2104,06,08)

or

datetime.date(2014,06,09)

I get an error

File "<stdin>", line 1
 datetime.date(2014,06,08)
                       ^
SyntaxError: invalid token

But when I remove the zero in '08' or '09' it works. The problem seems to be only with 8 and 9 and not with any other numbers. If anyone knows a work around, it would be great

like image 743
da4kc0m3dy Avatar asked Nov 20 '25 03:11

da4kc0m3dy


1 Answers

A number literal starting with 0 is interpreted as octal (base 8). 8 and 9 aren't octal digits.

Just don't use leading zeros.

like image 164
user2357112 supports Monica Avatar answered Nov 22 '25 16:11

user2357112 supports Monica



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!