SyntaxError invalid token

后端 未结 4 727
攒了一身酷
攒了一身酷 2020-12-05 09:16

I have a problem when I try to assign a value to a variable. The problem shows up when I try to put a date as a tuple or a list in this order: year, month, day.

4条回答
  •  青春惊慌失措
    2020-12-05 10:16

    In python version 2.7, we gets error when we use 0 before any number and that number is invalid in octal number system. For e.g. if we use 08 or 09 then we will encounter the same error 'invalid token'.

    Python interpreter divides the entire script into various parts and those parts are called tokens. Here, 08 will be consider as token and hence it is in octal and invalid in this number system so this kind of error occurs.

    Can you please try to run a simple statement like a=04 and mention the result? If it works and fail only while using tuple or list then it may be the issue with particular python version. If it does not work then there is something wrong with your machine configuration. In this case, you can upgrade your python version if you are using the older version.

提交回复
热议问题