Home>Article>Backend Development> What are the legal identifier requirements for python
Python legal identifier requirements are: 1. It cannot start with a number; 2. It cannot contain illegal characters; 3. Numbers cannot be used as identifiers; 4. It cannot contain spaces; 5. It cannot contain operators.
1. Cannot start with a number
>>> 2bin=2 File "", line 1 2bin=2 ^ SyntaxError: invalid syntax
2. Cannot contain illegal characters
>>> ssd@f=1 File "", line 1 ssd@f=1 ^ SyntaxError: invalid syntax
3. Numbers cannot be used as identifiers Symbol
>>> 123='wdsa' SyntaxError: can't assign to literal
4. Cannot contain spaces
>>> fds fds=1 File "", line 1 fds fds=1 ^ SyntaxError: invalid syntax
5. Cannot contain operators
>>> sdf+sdf=1 SyntaxError: can't assign to operator 6.python保留关键字不能作为标识符
Recommended tutorial: "Python Tutorial"
The above is the detailed content of What are the legal identifier requirements for python. For more information, please follow other related articles on the PHP Chinese website!