📜  python bytes to dict - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:04.036000             🧑  作者: Mango

代码示例2
# You can use indent option in json.dumps() to obtain \n symbols:

    import json

    user_dict = {'name': 'dinesh', 'code': 'dr-01'}
    user_encode_data = json.dumps(user_dict, indent=2).encode('utf-8')
    print(user_encode_data)

# Output:
    b'{\n  "name": "dinesh",\n  "code": "dr-01"\n}'