def convert_unicode_to_str(data):
        """
        Py2, always translate to utf8 from unicode
        Py3, always translate to unicode
        :param data:
        :return:
        """
        if six.PY2 and isinstance(data, six.text_type):
            return data.encode('utf8')
        elif six.PY3 and isinstance(data, six.binary_type):
            return data.decode('utf8')
        elif isinstance(data, collections.Mapping):
            return dict((Util.convert_unicode_to_str(k), Util.convert_unicode_to_str(v))
                        for k, v in six.iteritems(data))
        elif isinstance(data, collections.Iterable) and not isinstance(data, (six.binary_type, six.string_types)):
            return type(data)(map(Util.convert_unicode_to_str, data))

        return data
def convert_unicode_to_str ( data ) : if six . PY2 and isinstance ( data , six . text_type ) : return data . encode ( 'utf8' ) elif six . PY3 and isinstance ( data , six . binary_type ) : return data . decode ( 'utf8' ) elif isinstance ( data , collections . Mapping ) : return dict ( ( Util . convert_unicode_to_str ( k ) , Util . convert_unicode_to_str ( v ) ) for k , v in six . iteritems ( data ) ) elif isinstance ( data , collections . Iterable ) and not isinstance ( data , ( six . binary_type , six . string_types ) ) : return type ( data ) ( map ( Util . convert_unicode_to_str , data ) ) return data
Py2, always translate to utf8 from unicode
        Py3, always translate to unicode
        :param data:
        :return: