python: serialize a dictionary into a simple html output

前端 未结 9 647
轮回少年
轮回少年 2021-01-12 00:59

using app engine - yes i know all about django templates and other template engines.

Lets say i have a dictionary or a simple object, i dont know its structure and i

9条回答
  •  迷失自我
    2021-01-12 01:36

    Here's my simple solution, It can handle any level of nested dictionary.

    import json
    temp_text = {'decision': {'date_time': None, 'decision_type': None},
                 'not_received': {'date_time': '2019-04-15T19:18:43.825766'},
                 'received': {'date_time': None},
                 'rfi': {'date_time': None},
                 'under_review': {'date_time': None}}
    dict_text_for_html = json.dumps(
        temp_text, indent=4
    ).replace(' ', ' ').replace(',\n', ',
    ').replace('\n', '
    ')

    html view of python dict

提交回复
热议问题