I'm trying to convert that data type to string. Even that's not working. Example: str(0123) But this is possible a="0123". My complete assumption is 0123 is not accepted because it is octal not an integer. So, octal are not allowed in python. Please correct me if i'm wrong.
Asked
Active
Viewed 619 times
1
-
1Octal is `0o123`, but `0123` was allowed in Python2 for octal. But this is forbidden in Python3. – Daniel Apr 20 '19 at 11:48
1 Answers
0
You're looking for 0o123
. Numbers that start with only a zero, which is not the only symbol in the token, are invalid syntax.

ForceBru
- 43,482
- 10
- 63
- 98
-
@JohnColeman, that question has the Python-2.7 tag, so I'm not sure how this one is a dupe of that in the first place (although its [original version](https://stackoverflow.com/revisions/26749728/1) is tagged Python 3.x _as well as_ Python 2.7, while using Python 2.7's syntax for `print`). So, my answer about Python 3.x probably wouldn't fit the question about Python 2.7 – ForceBru Apr 20 '19 at 11:56
-
-
@ayhan, the OP of that post already knew that "the 0 for octal does not work any more in python (i.e. does not work in _python3_)", and their question was why Python didn't change the meaning of tokens like `001234`, that _don't_ start with `0o` in Python 3. [This question](https://stackoverflow.com/questions/11620151/what-do-numbers-starting-with-0-mean-in-python) may be a better dupe target. It's still tagged Python 2.7, tough, and it's not really about the difference between Py 2.7 and Py 3. – ForceBru Apr 20 '19 at 12:12