Today I learned python, however I just started with a SyntaxError : invalid syntax error, obviously there is nothing wrong with the code at all, but every time I run it, it shows "SyntaxError: invalid syntax".
"SyntaxError: invalid syntax" means python syntax error, after querying solved the problem, so summarize a solution for this problem:
SyntaxError : invalid syntax error solution: 1 version problem:
Because python2 and python3 are incompatible, some code that can run on python2 may not run on python3; try changing the version; SyntaxError : invalid syntax error Solution: 2 Path problem:
Remember to double-check that your path is correct; SyntaxError : invalid syntax error Solution: 3 Careless problem:
Forget to add the colon ( : ) at the end of if , elif , else , for , while , class , def statements;
Mistakenly using = as ==; SyntaxError : invalid syntax error Solution: 4 Installation of third-party modules encounters
The problem of "SyntaxError: invalid syntax" may also occur when installing third-party modules, so you need to check if some of them are installed in a cmd window, and at the same time, you need to go to the installation directory of python to find the directory where pip is located to install it.
I encountered a line of code error. Because the general common SyntaxError:invalid syntax error reporting reasons are: indentation format is not the same or the characters are Chinese input method. Finally summarize: python error SyntaxError:invalid syntax general reason for the characters in the English input problems or character mismatch, especially theColons and semicolons, dots and commasWrong number.
summarize
to this article on Python has been reporting errors SyntaxError: invalid syntax solution to this article, more related Python error SyntaxError: invalid syntax content, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future!