This article mainly introduces the interpreter and 3 for python 2.x in Windows. the method for coexistence of x is very convenient to be called in the command line. If you need it, you can refer to the following: Python2 and Python3 are incompatible. If you cannot upgrade to Python2, or if your colleagues stick to the Python2 camp, consider the coexistence of Python2 and Python3 in the system.
Mac OS X and Linux do not have to consider this situation. Because these Unix-like operating systems will directly map to Python3 when installing Python3. Install Python 2 and Python 3 at the same time.
Here we will only discuss Windows. Below are my common methods.
1. Create a D: \ Python folder;
2. Install Python 2.7 to D: \ Python27 and install Python 3.4 to D: \ Python34. Do not add Python to the path environment variable during installation;
3. create d: \ Python \ py2.bat with the following content:
D: \ Python \ 27 \ python.exe % *
4. create d: \ Python \ py3.bat with the following content:
D: \ Python \ 34 \ python.exe % *
5. Add D: \ Python to the environment variable PATH.
After such processing, you can directly input
Py3 yourpythonfile. py arg1 arg2
And Python2.