There are python 2.x and python 3.x. There are some different between them. Sometimes, we have to implement different processing for them. In this tutorial, we will introduce you how to do.
Here is the tutorial:
import six if six.PY2: print("this is python 2") if six.PY3: print("this is python 3")
In this code, we will use six package to check python version.
If you are running it on python 2.x, it will output: this is python 2, otherwise, it will output: this is python 3
Then we can implement different processing based on it.