SIX 是一个开源的Python库, 其设计目的是为了解决Python2和3的不兼容问题. 众所周知, Python 3是跟Python 2不兼容的, 其语法, 类库都有不一致的地方, 这给python程序员带来了极大不便, 但是, SIX的出世可以解决这一问题, 使用了SIX, 你的python程序可以同时运行在Python2或者Python3环境中, 而根本不需要修改.
SIX, 这个名字的来源就是
, SIX = Python2 Times Python3.
SIX的几个重要的特性:
隐藏Python2和3常量的差异
six.class_types
six.integer_types
six.string_types
six.text_types
six.binary_types
six.MAXSIZE
隐藏Python2和3语法的差异
six.exec_
six.print_
six.raise_from
six.reraise
six.with_metaclass
six.add_metaclass
隐藏Python2和3类库的差异
Six 提供了统一名字的标准库, 放到了six.moves中.