01 invalid token [duplicate]

房东的猫 提交于 2019-12-11 03:35:33

问题


Hey been learning python3 for a while.

Came across dictionaries and the dictionary_name.get() method and tried to get a random key value.

The problem:

data= {}

data.get('key',1)

it works and returns 1

But instead if I use data.get('key',01) it says invalid token why is that?


回答1:


In Python 2.x, integer literals starting with 0 were interpreted as octal numbers. In Python 3.x, octal numbers are written with the prefix 0o instead. To avoid that old code changes meaning without any warning, literals starting with just 0 are a syntax error now.



来源:https://stackoverflow.com/questions/25382405/01-invalid-token

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