问题
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