def params_filter(params, delimiter='&', charset='utf-8', excludes=['sign', 'sign_type']): if six.PY3: ks = sorted(params) else: ks = params.keys() ks.sort() newparams = {} prestr = '' if params.get('input_charset', None): charset = params['input_charset'] for k in ks: v = params[k] if k not in excludes and v != '': newparams[k] = v if six.PY3: k = smart_unicode(k) v = smart_unicode(v) prestr += '%s=%s%s' % (k, v, delimiter) prestr = prestr[:-1] return newparams, prestr
def params_encoding(params, charset='utf-8'): newparams = {} for k, v in params.items(): newparams[k] = smart_unicode(v) return newparams