django获取浏览器数据,处理格式——str 与 dict格式互转

注意要import json

import json
    def __init__(self, data_dict):
        self.data_dict= json.dumps(data_dict)
def dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True,
        allow_nan=True, cls=None, indent=None, separators=None,
        default=None, sort_keys=False, **kw):
    """Serialize ``obj`` to a JSON formatted ``str``.
import json
    def __init__(self, data_dict):
        self.data_dict= json.loads(data_dict)
def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
        parse_int=None, parse_constant=None, object_pairs_hook=None, **kw):
    """Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
    containing a JSON document) to a Python object.

你可能感兴趣的:(django获取浏览器数据,处理格式——str 与 dict格式互转)