Converting JSON to HTML table in Python

痞子三分冷 提交于 2019-12-03 08:56:42
Kyle Shrader

Try the following:

infoFromJson = json.loads(jsonfile)
print json2html.convert(json = infoFromJson)

The result from json2html.convert is a string.

If you don't have module:

$ pip install json2html

More examples here.

Nowadays it's better to use json2table (at least for Python 3)

import json2table
import json

infoFromJson = json.loads(jsonfile)
build_direction = "LEFT_TO_RIGHT"
table_attributes = {"style": "width:100%"}
print(json2table.convert(infoFromJson, 
                         build_direction=build_direction, 
                         table_attributes=table_attributes))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!