In Python 3, leading zeros are not allowed to numbers. For example:
05 0123
Etc. not allowed, but should be written as 5 and 123 .
In Python 2, however, a leading zero means that the number is an octal number (base eight), so 04 or 03 will mean 4 and 3 in octal, respectively, but 08 will be invalid because it is not a real octal number.
In Python 3, the octal syntax has changed to this:
0o10 0o4
(and also allow other bases, such as binary and hexadecimal, using the 0b or 0x prefixes.)
As for your other question, the token in Python is how the Python interpreter breaks your code into pieces so that it can understand it (see here ). Here, when the tokenizer tries to split your code, it does not expect to see zero there and therefore throws an error.
I would suggest (similar to other answers) that you drop the leading zero ( (2016,4,3) ) or represent them using strings ( ("2016","04","03") ).
Tuomas Laakkonen Apr 03 '16 at 14:16 2016-04-03 14:16
source share