six.moves module
six用于解决python2和python3的compatibility问题。其名字的含义是2*3=6.
用法举例:
1, 通过six.PY2和six.PY3可以判断当前运行环境的python版本。
2, six提供了six.integer_types, six.string_types, six.class_types, six.binary_type等变量来返回其在当前运行环境下的内容。即这些变量在python2和python3下都不相同。
3, 比如python3的urllib在python2中由urllib,urllib2和urlparse组成。
那么我们在文件头引入
from six.moves import urllib
再按照python3中的用法写代码,之后就可以compatible with both python2 and python3.