In Windows, the python 2.x interpreter and the 3.x interpreter coexist.
Python2 and Python3 are incompatible. If you encounter a situation where you cannot upgrade to Python2 code or your colleagues stick to the Python2 camp, you must 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.