leading zeros in python [duplicate]

泪湿孤枕 提交于 2019-12-06 14:03:55

Numbers with a leading zero in them are interpreted as octal, where the digits 8 and 9 don't exist.

It's worse in Python 3, leading zeros are a syntax error no matter which digits you use. See What’s New In Python 3.0 under "New octal literals". Also PEP 3127.

Valdogg21

When you start a number with a 0, Python sees it as an octal. So while yes, octal 04 is equal to decimal 04, but octal 08 does not even exist (because octal digits can only be in the range [0,7]).

Found here: Python: Invalid Token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!