On the difference between the octal number representation in Python2.6 and Python3.0
- 2020-05-30 20:32:02
- OfStack
There are two ways to represent base 8 in Python2.x: beginning with '0' and beginning with '0o' (letter o) :
Python2. 7:
>>> 0100
64
>>> 0o100
64
>>>
However, in Python3.x, the '0' prefix is abandoned, and only the '0o' prefix is supported:
Python3. 4:
>>> 0100
SyntaxError: invalid token
>>> 0o100
64