Problems that beginners often encounter when learning python.
1. python2 or python3?
New users often think about this for a long time. The syntaxes of 2 and 3 are roughly the same, but the changes are not significant. For example, print xxx in python2, and print (xxx) is used in python3 ), however, in the current situation, python3 will be the mainstream in the future, and the update speed of python3 on the official website will be faster than that of python2, so you can directly learn python3
2. Input python in the command line to display non-internal or external commands?
It must be the path that is not added to python.exe in the environment variable. Add the path to it.
3. Want to switch between python2 and python3?
You can change python.exeto python2.exeand python3.exe, and enter python2 or python3 in the command line. Remember to add the path to the environment variable (as described in section 2)
4. error?
This is really a big problem for new users. Especially those who do not have any programming experience, how can they solve it? Generally, the first line and the last line show the location of the error, and the last line shows the cause and type of the error. The Center is a function call error, for example:
A = 1/0
F: \ python3 \ python.exe C:/Users/Administrator/PycharmProjects/testApp/tyr. py
Traceback (most recent call last ):
File "C:/Users/Administrator/PycharmProjects/testApp/tyr. py", line 1, in <module>
A = 1/0
ZeroDivisionError: division by zero
This tells us that the error is in the first line, which is ZeroDivisionError (Division: 0). If there is no error, but you cannot get the expected result, it is a logical error, check the code.
5. IDLE or?
The selection of the compiling environment is very important. I personally suggest using pycharm, which has the Lenovo function, which can save a lot of trouble, but the method of use should be Baidu.