def stringify_dict(dct_or_tuples, encoding='utf-8', keys_only=True):
    """Return a (new) dict with unicode keys (and values when "keys_only" is
    False) of the given dict converted to strings. ``dct_or_tuples`` can be a
    dict or a list of tuples, like any dict constructor supports.
    """
    d = {}
    for k, v in six.iteritems(dict(dct_or_tuples)):
        k = k.encode(encoding) if isinstance(k, six.text_type) else k
        if not keys_only:
            v = v.encode(encoding) if isinstance(v, six.text_type) else v
        d[k] = v
    return d
Return a (new) dict with unicode keys (and values when "keys_only" is
    False) of the given dict converted to strings. ``dct_or_tuples`` can be a
    dict or a list of tuples, like any dict constructor supports.
    
stackoverflow/venv/lib/python3.6/site-packages/scrapy/utils/python.py