contexts
We all know that there are two major versions of python, one is python2 and the other is python3, so different people may be accustomed to different versions, and python2 and python3 and there are some differences and incompatibilities to the program apes caused a great deal of trouble, how to do?
corresponds English -ity, -ism, -ization
Six is the solution to this problem. It's a module designed to be compatible with Python 2 and Python 3, and it solves "well-known" problems such as the incompatibility of some of urllib's methods, and the incompatibility of the str and bytes types.
utilization
import six six.PY2 # Returns a boolean indicating whether the current operating environment is python2 or not six.PY3 # Returns a boolean indicating whether the current operating environment is python3. six.integer_types # In python2, there are two integer types, int and long; in python3, there is only one type, int. six.string_types # In python2, basestring is used; in python3, str is used. six.text_type # In python2, the type of text character used is unicode; in python3 the type of text character used is str six.binary_type # existpython2center,The type of byte sequence used isstr;existpython3centerThe type of byte sequence used isbytes
SIX function there are many, many, not commonly used here will not be listed, you can check the documentation when needed.
These are the basic points about SIX modules, thanks for learning and supporting me.